2008-09-18 03:15:49 +00:00
|
|
|
class CDebugTlb;
|
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
class 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_Changed ( void ) = 0;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|
|
|
|
|
2010-06-04 06:25:07 +00:00
|
|
|
class CTLB :
|
|
|
|
protected CSystemRegisters
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
public:
|
|
|
|
typedef struct {
|
|
|
|
bool EntryDefined;
|
|
|
|
union {
|
|
|
|
unsigned long Value;
|
|
|
|
unsigned char A[4];
|
|
|
|
|
|
|
|
struct {
|
|
|
|
unsigned zero : 13;
|
|
|
|
unsigned Mask : 12;
|
|
|
|
unsigned zero2 : 7;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
} PageMask;
|
|
|
|
|
|
|
|
union {
|
|
|
|
unsigned long Value;
|
|
|
|
unsigned char A[4];
|
|
|
|
|
|
|
|
struct {
|
|
|
|
unsigned ASID : 8;
|
|
|
|
unsigned Zero : 4;
|
|
|
|
unsigned G : 1;
|
|
|
|
unsigned VPN2 : 19;
|
|
|
|
};
|
|
|
|
|
|
|
|
} EntryHi;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
union {
|
|
|
|
unsigned long Value;
|
|
|
|
unsigned char A[4];
|
|
|
|
|
|
|
|
struct {
|
|
|
|
unsigned GLOBAL: 1;
|
|
|
|
unsigned V : 1;
|
|
|
|
unsigned D : 1;
|
|
|
|
unsigned C : 3;
|
|
|
|
unsigned PFN : 20;
|
|
|
|
unsigned ZERO: 6;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
} EntryLo0;
|
|
|
|
|
|
|
|
union {
|
|
|
|
unsigned long Value;
|
|
|
|
unsigned char A[4];
|
|
|
|
|
|
|
|
struct {
|
|
|
|
unsigned GLOBAL: 1;
|
|
|
|
unsigned V : 1;
|
|
|
|
unsigned D : 1;
|
|
|
|
unsigned C : 3;
|
|
|
|
unsigned PFN : 20;
|
|
|
|
unsigned ZERO: 6;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
} EntryLo1;
|
|
|
|
} TLB_ENTRY;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
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;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
TLB_ENTRY m_tlb[32];
|
|
|
|
FASTTLB m_FastTlb[64];
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
void SetupTLB_Entry ( int index, bool Random );
|
|
|
|
|
|
|
|
public:
|
2010-05-22 04:47:15 +00:00
|
|
|
CTLB ( CTLB_CB * CallBack );
|
2008-09-18 03:15:49 +00:00
|
|
|
~CTLB ( void );
|
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
void Reset ( bool InvalidateTLB );
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
//Used by opcodes of the same name to manipulate the tlb (reads the registers)
|
2010-05-22 04:47:15 +00:00
|
|
|
void Probe ( void );
|
|
|
|
void ReadEntry ( void );
|
|
|
|
void WriteEntry ( int index, bool Random );
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
//See if a VAddr has an entry to translate to a PAddr
|
2010-05-22 04:47:15 +00:00
|
|
|
bool AddressDefined ( DWORD VAddr );
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-06-04 06:25:07 +00:00
|
|
|
const TLB_ENTRY & TlbEntry ( int Entry) const { return m_tlb[Entry]; }
|
2010-06-22 20:36:28 +00:00
|
|
|
|
|
|
|
bool PAddrToVAddr ( DWORD PAddr, DWORD & VAddr, DWORD & Index );
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
//Change the Virtual address to a Phyiscal Address
|
2010-05-22 04:47:15 +00:00
|
|
|
/*inline bool TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
//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);
|
|
|
|
}
|
|
|
|
|
|
|
|
//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 );
|
|
|
|
|
|
|
|
//see if the Vaddr is valid
|
|
|
|
inline bool ValidVaddr ( DWORD VAddr ) const { return TLB_ReadMap[VAddr >> 12] != 0; }
|
2010-05-22 04:47:15 +00:00
|
|
|
*/
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|