Core: remove the global of g_TLB
This commit is contained in:
parent
c67f3f0e97
commit
5fec3f8d31
|
@ -27,6 +27,7 @@ const int32_t R4300iOp::LWR_SHIFT[4] = {24, 16, 8, 0};
|
|||
R4300iOp::R4300iOp(CN64System & System) :
|
||||
m_System(System),
|
||||
m_Reg(System.m_Reg),
|
||||
m_TLB(System.m_TLB),
|
||||
m_MMU(System.m_MMU_VM),
|
||||
m_PROGRAM_COUNTER(System.m_Reg.m_PROGRAM_COUNTER),
|
||||
m_GPR(System.m_Reg.m_GPR),
|
||||
|
@ -1462,7 +1463,7 @@ void R4300iOp::LL()
|
|||
m_LLBit = 1;
|
||||
uint32_t PhysicalAddr;
|
||||
bool MemoryUsed;
|
||||
g_TLB->VAddrToPAddr(Address, PhysicalAddr, MemoryUsed);
|
||||
m_TLB.VAddrToPAddr(Address, PhysicalAddr, MemoryUsed);
|
||||
m_CP0[17] = PhysicalAddr >> 4;
|
||||
}
|
||||
}
|
||||
|
@ -1508,7 +1509,7 @@ void R4300iOp::LLD()
|
|||
m_LLBit = 1;
|
||||
uint32_t PhysicalAddr;
|
||||
bool MemoryUsed;
|
||||
g_TLB->VAddrToPAddr(Address, PhysicalAddr, MemoryUsed);
|
||||
m_TLB.VAddrToPAddr(Address, PhysicalAddr, MemoryUsed);
|
||||
m_CP0[17] = PhysicalAddr >> 4;
|
||||
}
|
||||
}
|
||||
|
@ -2133,22 +2134,22 @@ void R4300iOp::COP0_DMT()
|
|||
|
||||
void R4300iOp::COP0_CO_TLBR()
|
||||
{
|
||||
g_TLB->ReadEntry();
|
||||
m_TLB.ReadEntry();
|
||||
}
|
||||
|
||||
void R4300iOp::COP0_CO_TLBWI()
|
||||
{
|
||||
g_TLB->WriteEntry(m_Reg.INDEX_REGISTER & 0x1F, false);
|
||||
m_TLB.WriteEntry(m_Reg.INDEX_REGISTER & 0x1F, false);
|
||||
}
|
||||
|
||||
void R4300iOp::COP0_CO_TLBWR()
|
||||
{
|
||||
g_TLB->WriteEntry(m_Reg.RANDOM_REGISTER & 0x1F, true);
|
||||
m_TLB.WriteEntry(m_Reg.RANDOM_REGISTER & 0x1F, true);
|
||||
}
|
||||
|
||||
void R4300iOp::COP0_CO_TLBP()
|
||||
{
|
||||
g_TLB->Probe();
|
||||
m_TLB.Probe();
|
||||
}
|
||||
|
||||
void R4300iOp::COP0_CO_ERET()
|
||||
|
|
|
@ -260,6 +260,7 @@ private:
|
|||
|
||||
CN64System & m_System;
|
||||
CRegisters & m_Reg;
|
||||
CTLB & m_TLB;
|
||||
CMipsMemoryVM & m_MMU;
|
||||
R4300iOpcode m_Opcode;
|
||||
uint32_t & m_PROGRAM_COUNTER;
|
||||
|
|
|
@ -19,6 +19,7 @@ uint32_t CMipsMemoryVM::RegModValue;
|
|||
CMipsMemoryVM::CMipsMemoryVM(CN64System & System, bool SavesReadOnly) :
|
||||
m_System(System),
|
||||
m_Reg(System.m_Reg),
|
||||
m_TLB(System.m_TLB),
|
||||
m_AudioInterfaceHandler(System, System.m_Reg),
|
||||
m_CartridgeDomain1Address1Handler(System.m_Reg, g_DDRom),
|
||||
m_CartridgeDomain2Address1Handler(System.m_Reg),
|
||||
|
@ -368,7 +369,7 @@ bool CMipsMemoryVM::LB_Memory(uint64_t VAddr, uint8_t & Value)
|
|||
{
|
||||
uint32_t PAddr;
|
||||
bool MemoryUnused;
|
||||
if (!g_TLB->VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
if (!m_TLB.VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
{
|
||||
m_Reg.TriggerAddressException(VAddr, MemoryUnused ? EXC_RADE : EXC_RMISS);
|
||||
return false;
|
||||
|
@ -400,7 +401,7 @@ bool CMipsMemoryVM::LH_Memory(uint64_t VAddr, uint16_t & Value)
|
|||
{
|
||||
uint32_t PAddr;
|
||||
bool MemoryUnused;
|
||||
if (!g_TLB->VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
if (!m_TLB.VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
{
|
||||
m_Reg.TriggerAddressException(VAddr, MemoryUnused ? EXC_RADE : EXC_RMISS);
|
||||
return false;
|
||||
|
@ -432,7 +433,7 @@ bool CMipsMemoryVM::LW_Memory(uint64_t VAddr, uint32_t & Value)
|
|||
{
|
||||
uint32_t PAddr;
|
||||
bool MemoryUnused;
|
||||
if (!g_TLB->VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
if (!m_TLB.VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
{
|
||||
m_Reg.TriggerAddressException(VAddr, MemoryUnused ? EXC_RADE : EXC_RMISS);
|
||||
return false;
|
||||
|
@ -464,7 +465,7 @@ bool CMipsMemoryVM::LD_Memory(uint64_t VAddr, uint64_t & Value)
|
|||
{
|
||||
uint32_t PAddr;
|
||||
bool MemoryUnused;
|
||||
if (!g_TLB->VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
if (!m_TLB.VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
{
|
||||
m_Reg.TriggerAddressException(VAddr, MemoryUnused ? EXC_RADE : EXC_RMISS);
|
||||
return false;
|
||||
|
@ -492,7 +493,7 @@ bool CMipsMemoryVM::SB_Memory(uint64_t VAddr, uint32_t Value)
|
|||
{
|
||||
uint32_t PAddr;
|
||||
bool MemoryUnused;
|
||||
if (!g_TLB->VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
if (!m_TLB.VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
{
|
||||
m_Reg.TriggerAddressException(VAddr, MemoryUnused ? EXC_WADE : EXC_WMISS);
|
||||
return false;
|
||||
|
@ -524,7 +525,7 @@ bool CMipsMemoryVM::SH_Memory(uint64_t VAddr, uint32_t Value)
|
|||
{
|
||||
uint32_t PAddr;
|
||||
bool MemoryUnused;
|
||||
if (!g_TLB->VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
if (!m_TLB.VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
{
|
||||
m_Reg.TriggerAddressException(VAddr, MemoryUnused ? EXC_WADE : EXC_WMISS);
|
||||
return false;
|
||||
|
@ -556,7 +557,7 @@ bool CMipsMemoryVM::SW_Memory(uint64_t VAddr, uint32_t Value)
|
|||
{
|
||||
uint32_t PAddr;
|
||||
bool MemoryUnused;
|
||||
if (!g_TLB->VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
if (!m_TLB.VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
{
|
||||
m_Reg.TriggerAddressException(VAddr, MemoryUnused ? EXC_WADE : EXC_WMISS);
|
||||
return false;
|
||||
|
@ -588,7 +589,7 @@ bool CMipsMemoryVM::SD_Memory(uint64_t VAddr, uint64_t Value)
|
|||
{
|
||||
uint32_t PAddr;
|
||||
bool MemoryUnused;
|
||||
if (!g_TLB->VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
if (!m_TLB.VAddrToPAddr(VAddr, PAddr, MemoryUnused))
|
||||
{
|
||||
m_Reg.TriggerAddressException(VAddr, MemoryUnused ? EXC_WADE : EXC_WMISS);
|
||||
return false;
|
||||
|
|
|
@ -211,6 +211,7 @@ private:
|
|||
static uint8_t *m_Reserve1, *m_Reserve2;
|
||||
CN64System & m_System;
|
||||
CRegisters & m_Reg;
|
||||
CTLB & m_TLB;
|
||||
AudioInterfaceHandler m_AudioInterfaceHandler;
|
||||
CartridgeDomain1Address1Handler m_CartridgeDomain1Address1Handler;
|
||||
CartridgeDomain1Address3Handler m_CartridgeDomain1Address3Handler;
|
||||
|
|
|
@ -899,6 +899,11 @@ void CN64System::ApplyGSButton(void)
|
|||
}
|
||||
}
|
||||
|
||||
CTLB & CN64System::TLB()
|
||||
{
|
||||
return m_TLB;
|
||||
}
|
||||
|
||||
void CN64System::Reset(bool bInitReg, bool ClearMenory)
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "Start (bInitReg: %s, ClearMenory: %s)", bInitReg ? "true" : "false", ClearMenory ? "true" : "false");
|
||||
|
@ -969,7 +974,6 @@ bool CN64System::SetActiveSystem(bool bActive)
|
|||
}
|
||||
g_Recompiler = m_Recomp;
|
||||
g_MMU = &m_MMU_VM;
|
||||
g_TLB = &m_TLB;
|
||||
g_Reg = &m_Reg;
|
||||
g_Mempak = &m_Mempak;
|
||||
g_SystemTimer = &m_SystemTimer;
|
||||
|
@ -988,7 +992,6 @@ bool CN64System::SetActiveSystem(bool bActive)
|
|||
g_SyncSystem = nullptr;
|
||||
g_Recompiler = nullptr;
|
||||
g_MMU = nullptr;
|
||||
g_TLB = nullptr;
|
||||
g_Reg = nullptr;
|
||||
g_SystemTimer = nullptr;
|
||||
g_NextTimer = nullptr;
|
||||
|
|
|
@ -88,6 +88,7 @@ public:
|
|||
{
|
||||
return m_OpCodes.Opcode();
|
||||
}
|
||||
CTLB & TLB();
|
||||
void Reset(bool bInitReg, bool ClearMenory);
|
||||
void GameReset();
|
||||
void PluginReset();
|
||||
|
|
|
@ -9,6 +9,7 @@ CRecompiler::CRecompiler(CN64System & System, bool & EndEmulation) :
|
|||
m_System(System),
|
||||
m_MMU(System.m_MMU_VM),
|
||||
m_Reg(System.m_Reg),
|
||||
m_TLB(System.m_TLB),
|
||||
m_EndEmulation(EndEmulation),
|
||||
m_MemoryStack(0),
|
||||
PROGRAM_COUNTER(System.m_Reg.m_PROGRAM_COUNTER),
|
||||
|
@ -447,7 +448,7 @@ void CRecompiler::ClearRecompCode_Phys(uint32_t Address, int length, REMOVE_REAS
|
|||
ClearRecompCode_Virt(Address + 0xA0000000, length, Reason);
|
||||
|
||||
uint32_t VAddr, Index = 0;
|
||||
while (g_TLB->PAddrToVAddr(Address, VAddr, Index))
|
||||
while (m_TLB.PAddrToVAddr(Address, VAddr, Index))
|
||||
{
|
||||
WriteTrace(TraceRecompiler, TraceInfo, "ClearRecompCode Vaddr %X len: %d", VAddr, length);
|
||||
ClearRecompCode_Virt(VAddr, length, Reason);
|
||||
|
|
|
@ -83,6 +83,7 @@ private:
|
|||
CN64System & m_System;
|
||||
CMipsMemoryVM & m_MMU;
|
||||
CRegisters & m_Reg;
|
||||
CTLB & m_TLB;
|
||||
bool & m_EndEmulation;
|
||||
uint8_t * m_MemoryStack;
|
||||
FUNCTION_PROFILE m_BlockProfile;
|
||||
|
|
|
@ -7,6 +7,7 @@ CRecompilerOpsBase::CRecompilerOpsBase(CN64System & System, CCodeBlock & CodeBlo
|
|||
m_System(System),
|
||||
m_SystemEvents(System.m_SystemEvents),
|
||||
m_Reg(System.m_Reg),
|
||||
m_TLB(System.m_TLB),
|
||||
m_MMU(System.m_MMU_VM),
|
||||
m_CodeBlock(CodeBlock),
|
||||
m_Section(nullptr)
|
||||
|
|
|
@ -43,6 +43,7 @@ class CN64System;
|
|||
class CSystemEvents;
|
||||
class CMipsMemoryVM;
|
||||
class CRegisters;
|
||||
class CTLB;
|
||||
|
||||
class CRecompilerOpsBase :
|
||||
protected CDebugSettings
|
||||
|
@ -55,6 +56,7 @@ protected:
|
|||
CSystemEvents & m_SystemEvents;
|
||||
CMipsMemoryVM & m_MMU;
|
||||
CRegisters & m_Reg;
|
||||
CTLB & m_TLB;
|
||||
CCodeBlock & m_CodeBlock;
|
||||
R4300iOpcode m_Opcode;
|
||||
CCodeSection * m_Section;
|
||||
|
|
|
@ -7384,7 +7384,7 @@ void CX86RecompilerOps::COP0_DMT()
|
|||
void CX86RecompilerOps::COP0_CO_TLBR(void)
|
||||
{
|
||||
m_RegWorkingSet.BeforeCallDirect();
|
||||
m_Assembler.CallThis((uint32_t)g_TLB, AddressOf(&CTLB::ReadEntry), "CTLB::ReadEntry", 4);
|
||||
m_Assembler.CallThis((uint32_t)&m_TLB, AddressOf(&CTLB::ReadEntry), "CTLB::ReadEntry", 4);
|
||||
m_RegWorkingSet.AfterCallDirect();
|
||||
}
|
||||
|
||||
|
@ -7395,7 +7395,7 @@ void CX86RecompilerOps::COP0_CO_TLBWI(void)
|
|||
m_Assembler.MoveVariableToX86reg(asmjit::x86::ecx, &g_Reg->INDEX_REGISTER, "INDEX_REGISTER");
|
||||
m_Assembler.and_(asmjit::x86::ecx, 0x1F);
|
||||
m_Assembler.push(asmjit::x86::ecx);
|
||||
m_Assembler.CallThis((uint32_t)g_TLB, AddressOf(&CTLB::WriteEntry), "CTLB::WriteEntry", 12);
|
||||
m_Assembler.CallThis((uint32_t)&m_TLB, AddressOf(&CTLB::WriteEntry), "CTLB::WriteEntry", 12);
|
||||
m_RegWorkingSet.AfterCallDirect();
|
||||
}
|
||||
|
||||
|
@ -7408,14 +7408,14 @@ void CX86RecompilerOps::COP0_CO_TLBWR(void)
|
|||
m_Assembler.MoveVariableToX86reg(asmjit::x86::ecx, &g_Reg->RANDOM_REGISTER, "RANDOM_REGISTER");
|
||||
m_Assembler.and_(asmjit::x86::ecx, 0x1F);
|
||||
m_Assembler.push(asmjit::x86::ecx);
|
||||
m_Assembler.CallThis((uint32_t)g_TLB, AddressOf(&CTLB::WriteEntry), "CTLB::WriteEntry", 12);
|
||||
m_Assembler.CallThis((uint32_t)&m_TLB, AddressOf(&CTLB::WriteEntry), "CTLB::WriteEntry", 12);
|
||||
m_RegWorkingSet.AfterCallDirect();
|
||||
}
|
||||
|
||||
void CX86RecompilerOps::COP0_CO_TLBP(void)
|
||||
{
|
||||
m_RegWorkingSet.BeforeCallDirect();
|
||||
m_Assembler.CallThis((uint32_t)g_TLB, AddressOf(&CTLB::Probe), "CTLB::TLB_Probe", 4);
|
||||
m_Assembler.CallThis((uint32_t)&m_TLB, AddressOf(&CTLB::Probe), "CTLB::TLB_Probe", 4);
|
||||
m_RegWorkingSet.AfterCallDirect();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ CN64System * g_BaseSystem = nullptr;
|
|||
CN64System * g_SyncSystem = nullptr;
|
||||
CRecompiler * g_Recompiler = nullptr;
|
||||
CMipsMemoryVM * g_MMU = nullptr; // Memory of the N64
|
||||
CTLB * g_TLB = nullptr; // TLB unit
|
||||
CRegisters * g_Reg = nullptr; // Current register set attached to the g_MMU
|
||||
CNotification * g_Notify = nullptr;
|
||||
CPlugins * g_Plugins = nullptr;
|
||||
|
|
|
@ -14,9 +14,6 @@ extern CRecompiler * g_Recompiler;
|
|||
class CMipsMemoryVM;
|
||||
extern CMipsMemoryVM * g_MMU; // Memory of the N64
|
||||
|
||||
class CTLB;
|
||||
extern CTLB * g_TLB; // TLB unit
|
||||
|
||||
class CRegisters;
|
||||
extern CRegisters * g_Reg; // Current register set attached to the g_MMU
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ void CDebugTlb::RefreshTLBWindow(void)
|
|||
LV_ITEM item, OldItem;
|
||||
int count;
|
||||
|
||||
TLB_ENTRY * tlb = g_TLB->m_tlb;
|
||||
TLB_ENTRY * tlb = g_System->TLB().m_tlb;
|
||||
for (count = 0; count < 32; count++)
|
||||
{
|
||||
swprintf(Output, sizeof(Output), L"0x%02X", count);
|
||||
|
@ -202,7 +202,7 @@ void CDebugTlb::RefreshTLBWindow(void)
|
|||
}
|
||||
}
|
||||
|
||||
CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb;
|
||||
CTLB::FASTTLB * FastTlb = g_System->TLB().m_FastTlb;
|
||||
hList = GetDlgItem(IDC_LIST2);
|
||||
for (count = 0; count < 64; count++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue