2012-12-19 09:30:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
2015-12-06 09:59:58 +00:00
|
|
|
#include <Common/LogClass.h>
|
2016-01-13 11:15:30 +00:00
|
|
|
#include <Project64-core/N64System/Mips/RegisterClass.h>
|
2015-12-06 09:59:58 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
class CDebugTlb;
|
|
|
|
|
2015-11-09 06:21:32 +00:00
|
|
|
__interface CTLB_CB
|
2010-05-22 04:47:15 +00:00
|
|
|
{
|
2015-11-09 06:21:32 +00:00
|
|
|
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;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|
|
|
|
|
2015-11-09 06:21:32 +00:00
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union
|
|
|
|
|
2010-06-04 06:25:07 +00:00
|
|
|
class CTLB :
|
2015-11-09 06:21:32 +00:00
|
|
|
protected CSystemRegisters
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
public:
|
2015-11-09 06:21:32 +00:00
|
|
|
struct TLB_ENTRY
|
|
|
|
{
|
|
|
|
bool EntryDefined;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
uint32_t Value;
|
|
|
|
uint8_t A[4];
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned zero : 13;
|
|
|
|
unsigned Mask : 12;
|
|
|
|
unsigned zero2 : 7;
|
2015-12-10 19:08:39 +00:00
|
|
|
};
|
2015-11-09 06:21:32 +00:00
|
|
|
} PageMask;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
uint32_t Value;
|
|
|
|
uint8_t A[4];
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned ASID : 8;
|
|
|
|
unsigned Zero : 4;
|
|
|
|
unsigned G : 1;
|
|
|
|
unsigned VPN2 : 19;
|
|
|
|
};
|
|
|
|
} EntryHi;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
uint32_t Value;
|
|
|
|
uint8_t A[4];
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
2015-12-10 19:08:39 +00:00
|
|
|
unsigned GLOBAL : 1;
|
2015-11-09 06:21:32 +00:00
|
|
|
unsigned V : 1;
|
|
|
|
unsigned D : 1;
|
|
|
|
unsigned C : 3;
|
|
|
|
unsigned PFN : 20;
|
2015-12-10 19:08:39 +00:00
|
|
|
unsigned ZERO : 6;
|
|
|
|
};
|
2015-11-09 06:21:32 +00:00
|
|
|
} EntryLo0;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
uint32_t Value;
|
|
|
|
uint8_t A[4];
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
2015-12-10 19:08:39 +00:00
|
|
|
unsigned GLOBAL : 1;
|
2015-11-09 06:21:32 +00:00
|
|
|
unsigned V : 1;
|
|
|
|
unsigned D : 1;
|
|
|
|
unsigned C : 3;
|
|
|
|
unsigned PFN : 20;
|
2015-12-10 19:08:39 +00:00
|
|
|
unsigned ZERO : 6;
|
|
|
|
};
|
2015-11-09 06:21:32 +00:00
|
|
|
} EntryLo1;
|
|
|
|
};
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
public:
|
2015-11-09 06:21:32 +00:00
|
|
|
CTLB(CTLB_CB * CallBack);
|
|
|
|
~CTLB();
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-11-09 06:21:32 +00:00
|
|
|
void Reset(bool InvalidateTLB);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-11-09 06:21:32 +00:00
|
|
|
//Used by opcodes of the same name to manipulate the tlb (reads the registers)
|
|
|
|
void Probe();
|
|
|
|
void ReadEntry();
|
|
|
|
void WriteEntry(int32_t index, bool Random);
|
2010-06-22 20:36:28 +00:00
|
|
|
|
2015-11-09 06:21:32 +00:00
|
|
|
//See if a VAddr has an entry to translate to a PAddr
|
|
|
|
bool AddressDefined(uint32_t VAddr);
|
2010-06-22 20:36:28 +00:00
|
|
|
|
2015-11-09 06:21:32 +00:00
|
|
|
const TLB_ENTRY & TlbEntry(int32_t Entry) const
|
|
|
|
{
|
|
|
|
return m_tlb[Entry];
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-11-09 06:21:32 +00:00
|
|
|
bool PAddrToVAddr(uint32_t PAddr, uint32_t & VAddr, uint32_t & Index);
|
|
|
|
|
|
|
|
void RecordDifference(CLog &LogFile, const CTLB& rTLB);
|
|
|
|
|
|
|
|
bool operator == (const CTLB& rTLB) const;
|
|
|
|
bool operator != (const CTLB& rTLB) const;
|
2012-09-28 20:17:44 +00:00
|
|
|
|
|
|
|
private:
|
2015-11-09 06:21:32 +00:00
|
|
|
struct FASTTLB
|
|
|
|
{
|
|
|
|
uint32_t VSTART;
|
|
|
|
uint32_t VEND;
|
|
|
|
uint32_t PHYSSTART;
|
|
|
|
uint32_t PHYSEND;
|
|
|
|
uint32_t Length;
|
|
|
|
bool VALID;
|
|
|
|
bool DIRTY;
|
|
|
|
bool GLOBAL;
|
|
|
|
bool ValidEntry;
|
|
|
|
bool Random;
|
|
|
|
bool Probed;
|
|
|
|
};
|
|
|
|
|
2016-11-27 20:28:13 +00:00
|
|
|
friend class CDebugTlb; // enable debug window to read class
|
2015-11-09 06:21:32 +00:00
|
|
|
|
|
|
|
CTLB_CB * const m_CB;
|
|
|
|
|
|
|
|
TLB_ENTRY m_tlb[32];
|
|
|
|
FASTTLB m_FastTlb[64];
|
|
|
|
|
|
|
|
void SetupTLB_Entry(int32_t index, bool Random);
|
|
|
|
|
|
|
|
private:
|
2021-04-13 00:07:11 +00:00
|
|
|
CTLB();
|
|
|
|
CTLB(const CTLB&);
|
|
|
|
CTLB& operator=(const CTLB&);
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|
2015-11-09 06:21:32 +00:00
|
|
|
|
|
|
|
#pragma warning(pop)
|