mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-01 21:58:48 +00:00
Revert "PPCCache: Avoid Global System Accessor"
This reverts commit cf74c0d683
.
This commit is contained in:
parent
0a671d3fff
commit
d08c3b9026
12 changed files with 118 additions and 119 deletions
|
@ -1082,14 +1082,6 @@ public:
|
|||
ABI_CallFunction(func);
|
||||
}
|
||||
|
||||
template <typename FunctionPointer>
|
||||
void ABI_CallFunctionPP(FunctionPointer func, const void* param1, const void* param2)
|
||||
{
|
||||
MOV(64, R(ABI_PARAM1), Imm64(reinterpret_cast<u64>(param1)));
|
||||
MOV(64, R(ABI_PARAM2), Imm64(reinterpret_cast<u64>(param2)));
|
||||
ABI_CallFunction(func);
|
||||
}
|
||||
|
||||
template <typename FunctionPointer>
|
||||
void ABI_CallFunctionPC(FunctionPointer func, const void* param1, u32 param2)
|
||||
{
|
||||
|
|
|
@ -273,11 +273,9 @@ static Installation InstallCodeHandlerLocked(const Core::CPUThreadGuard& guard)
|
|||
|
||||
// Invalidate the icache and any asm codes
|
||||
auto& ppc_state = guard.GetSystem().GetPPCState();
|
||||
auto& memory = guard.GetSystem().GetMemory();
|
||||
auto& jit_interface = guard.GetSystem().GetJitInterface();
|
||||
for (u32 j = 0; j < (codelist_end_address - codelist_base_address); j += 32)
|
||||
for (u32 j = 0; j < (INSTALLER_END_ADDRESS - INSTALLER_BASE_ADDRESS); j += 32)
|
||||
{
|
||||
ppc_state.iCache.Invalidate(memory, jit_interface, codelist_base_address + j);
|
||||
ppc_state.iCache.Invalidate(INSTALLER_BASE_ADDRESS + j);
|
||||
}
|
||||
return Installation::Installed;
|
||||
}
|
||||
|
|
|
@ -68,14 +68,12 @@ constexpr std::array<Hook, 23> os_patches{{
|
|||
void Patch(Core::System& system, u32 addr, std::string_view func_name)
|
||||
{
|
||||
auto& ppc_state = system.GetPPCState();
|
||||
auto& memory = system.GetMemory();
|
||||
auto& jit_interface = system.GetJitInterface();
|
||||
for (u32 i = 1; i < os_patches.size(); ++i)
|
||||
{
|
||||
if (os_patches[i].name == func_name)
|
||||
{
|
||||
s_hooked_addresses[addr] = i;
|
||||
ppc_state.iCache.Invalidate(memory, jit_interface, addr);
|
||||
ppc_state.iCache.Invalidate(addr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -157,8 +155,6 @@ void PatchFunctions(Core::System& system)
|
|||
{
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
auto& ppc_state = power_pc.GetPPCState();
|
||||
auto& memory = system.GetMemory();
|
||||
auto& jit_interface = system.GetJitInterface();
|
||||
auto& ppc_symbol_db = power_pc.GetSymbolDB();
|
||||
|
||||
// Remove all hooks that aren't fixed address hooks
|
||||
|
@ -166,7 +162,7 @@ void PatchFunctions(Core::System& system)
|
|||
{
|
||||
if (os_patches[i->second].flags != HookFlag::Fixed)
|
||||
{
|
||||
ppc_state.iCache.Invalidate(memory, jit_interface, i->first);
|
||||
ppc_state.iCache.Invalidate(i->first);
|
||||
i = s_hooked_addresses.erase(i);
|
||||
}
|
||||
else
|
||||
|
@ -186,7 +182,7 @@ void PatchFunctions(Core::System& system)
|
|||
for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4)
|
||||
{
|
||||
s_hooked_addresses[addr] = i;
|
||||
ppc_state.iCache.Invalidate(memory, jit_interface, addr);
|
||||
ppc_state.iCache.Invalidate(addr);
|
||||
}
|
||||
INFO_LOG_FMT(OSHLE, "Patching {} {:08x}", os_patches[i].name, symbol->address);
|
||||
}
|
||||
|
@ -285,8 +281,6 @@ u32 UnPatch(Core::System& system, std::string_view patch_name)
|
|||
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
auto& ppc_state = power_pc.GetPPCState();
|
||||
auto& memory = system.GetMemory();
|
||||
auto& jit_interface = system.GetJitInterface();
|
||||
|
||||
if (patch->flags == HookFlag::Fixed)
|
||||
{
|
||||
|
@ -298,7 +292,7 @@ u32 UnPatch(Core::System& system, std::string_view patch_name)
|
|||
if (i->second == patch_idx)
|
||||
{
|
||||
addr = i->first;
|
||||
ppc_state.iCache.Invalidate(memory, jit_interface, i->first);
|
||||
ppc_state.iCache.Invalidate(i->first);
|
||||
i = s_hooked_addresses.erase(i);
|
||||
}
|
||||
else
|
||||
|
@ -316,7 +310,7 @@ u32 UnPatch(Core::System& system, std::string_view patch_name)
|
|||
for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4)
|
||||
{
|
||||
s_hooked_addresses.erase(addr);
|
||||
ppc_state.iCache.Invalidate(memory, jit_interface, addr);
|
||||
ppc_state.iCache.Invalidate(addr);
|
||||
}
|
||||
return symbol->address;
|
||||
}
|
||||
|
@ -327,8 +321,6 @@ u32 UnPatch(Core::System& system, std::string_view patch_name)
|
|||
u32 UnpatchRange(Core::System& system, u32 start_addr, u32 end_addr)
|
||||
{
|
||||
auto& ppc_state = system.GetPPCState();
|
||||
auto& memory = system.GetMemory();
|
||||
auto& jit_interface = system.GetJitInterface();
|
||||
|
||||
u32 count = 0;
|
||||
|
||||
|
@ -337,7 +329,7 @@ u32 UnpatchRange(Core::System& system, u32 start_addr, u32 end_addr)
|
|||
{
|
||||
INFO_LOG_FMT(OSHLE, "Unpatch HLE hooks [{:08x};{:08x}): {} at {:08x}", start_addr, end_addr,
|
||||
os_patches[i->second].name, i->first);
|
||||
ppc_state.iCache.Invalidate(memory, jit_interface, i->first);
|
||||
ppc_state.iCache.Invalidate(i->first);
|
||||
i = s_hooked_addresses.erase(i);
|
||||
count += 1;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,6 @@ void GeckoCodeHandlerICacheFlush(const Core::CPUThreadGuard& guard)
|
|||
{
|
||||
auto& system = guard.GetSystem();
|
||||
auto& ppc_state = system.GetPPCState();
|
||||
auto& jit_interface = system.GetJitInterface();
|
||||
|
||||
// Work around the codehandler not properly invalidating the icache, but
|
||||
// only the first few frames.
|
||||
|
@ -95,7 +94,7 @@ void GeckoCodeHandlerICacheFlush(const Core::CPUThreadGuard& guard)
|
|||
}
|
||||
PowerPC::MMU::HostWrite_U32(guard, gch_gameid + 1, codelist_hook);
|
||||
|
||||
ppc_state.iCache.Reset(jit_interface);
|
||||
ppc_state.iCache.Reset();
|
||||
}
|
||||
|
||||
// Because Dolphin messes around with the CPU state instead of patching the game binary, we
|
||||
|
|
|
@ -1015,8 +1015,7 @@ void ProcessCommands(bool loop_until_continue)
|
|||
|
||||
WriteMemory(guard);
|
||||
auto& ppc_state = system.GetPPCState();
|
||||
auto& jit_interface = system.GetJitInterface();
|
||||
ppc_state.iCache.Reset(jit_interface);
|
||||
ppc_state.iCache.Reset();
|
||||
Host_UpdateDisasmDialog();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -631,9 +631,7 @@ void Interpreter::icbi(Interpreter& interpreter, UGeckoInstruction inst)
|
|||
// TODO: Raise DSI if translation fails (except for direct-store segments).
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_X(ppc_state, inst);
|
||||
auto& memory = interpreter.m_system.GetMemory();
|
||||
auto& jit_interface = interpreter.m_system.GetJitInterface();
|
||||
ppc_state.iCache.Invalidate(memory, jit_interface, address);
|
||||
ppc_state.iCache.Invalidate(address);
|
||||
}
|
||||
|
||||
void Interpreter::lbzux(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
|
|
|
@ -358,8 +358,7 @@ void Interpreter::mtspr(Interpreter& interpreter, UGeckoInstruction inst)
|
|||
INFO_LOG_FMT(POWERPC, "Flush Instruction Cache! ICE={}", HID0(ppc_state).ICE);
|
||||
// this is rather slow
|
||||
// most games do it only once during initialization
|
||||
auto& jit_interface = interpreter.m_system.GetJitInterface();
|
||||
ppc_state.iCache.Reset(jit_interface);
|
||||
ppc_state.iCache.Reset();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -217,9 +217,9 @@ void Jit64::UpdateFPExceptionSummary(X64Reg fpscr, X64Reg tmp1, X64Reg tmp2)
|
|||
OR(32, R(fpscr), R(tmp1));
|
||||
}
|
||||
|
||||
static void DoICacheReset(PowerPC::PowerPCState& ppc_state, JitInterface& jit_interface)
|
||||
static void DoICacheReset(PowerPC::PowerPCState& ppc_state)
|
||||
{
|
||||
ppc_state.iCache.Reset(jit_interface);
|
||||
ppc_state.iCache.Reset();
|
||||
}
|
||||
|
||||
void Jit64::mtspr(UGeckoInstruction inst)
|
||||
|
@ -287,7 +287,7 @@ void Jit64::mtspr(UGeckoInstruction inst)
|
|||
FixupBranch dont_reset_icache = J_CC(CC_NC);
|
||||
BitSet32 regs = CallerSavedRegistersInUse();
|
||||
ABI_PushRegistersAndAdjustStack(regs, 0);
|
||||
ABI_CallFunctionPP(DoICacheReset, &m_ppc_state, &m_system.GetJitInterface());
|
||||
ABI_CallFunctionP(DoICacheReset, &m_ppc_state);
|
||||
ABI_PopRegistersAndAdjustStack(regs, 0);
|
||||
SetJumpTarget(dont_reset_icache);
|
||||
return;
|
||||
|
|
|
@ -220,7 +220,7 @@ T MMU::ReadFromHardware(u32 em_address)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_ppc_state.dCache.Read(m_memory, em_address, &value, sizeof(T),
|
||||
m_ppc_state.dCache.Read(em_address, &value, sizeof(T),
|
||||
HID0(m_ppc_state).DLOCK || flag != XCheckTLBFlag::Read);
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ T MMU::ReadFromHardware(u32 em_address)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_ppc_state.dCache.Read(m_memory, em_address + 0x10000000, &value, sizeof(T),
|
||||
m_ppc_state.dCache.Read(em_address + 0x10000000, &value, sizeof(T),
|
||||
HID0(m_ppc_state).DLOCK || flag != XCheckTLBFlag::Read);
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,7 @@ void MMU::WriteToHardware(u32 em_address, const u32 data, const u32 size)
|
|||
em_address &= m_memory.GetRamMask();
|
||||
|
||||
if (m_ppc_state.m_enable_dcache && !wi)
|
||||
m_ppc_state.dCache.Write(m_memory, em_address, &swapped_data, size, HID0(m_ppc_state).DLOCK);
|
||||
m_ppc_state.dCache.Write(em_address, &swapped_data, size, HID0(m_ppc_state).DLOCK);
|
||||
|
||||
if (!m_ppc_state.m_enable_dcache || wi || flag != XCheckTLBFlag::Write)
|
||||
std::memcpy(&m_memory.GetRAM()[em_address], &swapped_data, size);
|
||||
|
@ -427,7 +427,7 @@ void MMU::WriteToHardware(u32 em_address, const u32 data, const u32 size)
|
|||
|
||||
if (m_ppc_state.m_enable_dcache && !wi)
|
||||
{
|
||||
m_ppc_state.dCache.Write(m_memory, em_address + 0x10000000, &swapped_data, size,
|
||||
m_ppc_state.dCache.Write(em_address + 0x10000000, &swapped_data, size,
|
||||
HID0(m_ppc_state).DLOCK);
|
||||
}
|
||||
|
||||
|
@ -497,7 +497,7 @@ TryReadInstResult MMU::TryReadInstruction(u32 address)
|
|||
}
|
||||
else
|
||||
{
|
||||
hex = m_ppc_state.iCache.ReadInstruction(m_memory, m_ppc_state, address);
|
||||
hex = m_ppc_state.iCache.ReadInstruction(address);
|
||||
}
|
||||
return TryReadInstResult{true, from_bat, hex, address};
|
||||
}
|
||||
|
@ -1137,7 +1137,7 @@ void MMU::StoreDCacheLine(u32 address)
|
|||
}
|
||||
|
||||
if (m_ppc_state.m_enable_dcache)
|
||||
m_ppc_state.dCache.Store(m_memory, address);
|
||||
m_ppc_state.dCache.Store(address);
|
||||
}
|
||||
|
||||
void MMU::InvalidateDCacheLine(u32 address)
|
||||
|
@ -1159,7 +1159,7 @@ void MMU::InvalidateDCacheLine(u32 address)
|
|||
}
|
||||
|
||||
if (m_ppc_state.m_enable_dcache)
|
||||
m_ppc_state.dCache.Invalidate(m_memory, address);
|
||||
m_ppc_state.dCache.Invalidate(address);
|
||||
}
|
||||
|
||||
void MMU::FlushDCacheLine(u32 address)
|
||||
|
@ -1183,7 +1183,7 @@ void MMU::FlushDCacheLine(u32 address)
|
|||
}
|
||||
|
||||
if (m_ppc_state.m_enable_dcache)
|
||||
m_ppc_state.dCache.Flush(m_memory, address);
|
||||
m_ppc_state.dCache.Flush(address);
|
||||
}
|
||||
|
||||
void MMU::TouchDCacheLine(u32 address, bool store)
|
||||
|
@ -1207,7 +1207,7 @@ void MMU::TouchDCacheLine(u32 address, bool store)
|
|||
}
|
||||
|
||||
if (m_ppc_state.m_enable_dcache)
|
||||
m_ppc_state.dCache.Touch(m_memory, address, store);
|
||||
m_ppc_state.dCache.Touch(address, store);
|
||||
}
|
||||
|
||||
u32 MMU::IsOptimizableMMIOAccess(u32 address, u32 access_size) const
|
||||
|
|
|
@ -105,14 +105,17 @@ void Cache::Reset()
|
|||
std::fill(lookup_table_vmem.begin(), lookup_table_vmem.end(), 0xFF);
|
||||
}
|
||||
|
||||
void InstructionCache::Reset(JitInterface& jit_interface)
|
||||
void InstructionCache::Reset()
|
||||
{
|
||||
Cache::Reset();
|
||||
jit_interface.ClearSafe();
|
||||
Core::System::GetInstance().GetJitInterface().ClearSafe();
|
||||
}
|
||||
|
||||
void Cache::Init(Memory::MemoryManager& memory)
|
||||
void Cache::Init()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
data.fill({});
|
||||
addrs.fill({});
|
||||
lookup_table.resize(memory.GetRamSize() >> 5);
|
||||
|
@ -121,18 +124,21 @@ void Cache::Init(Memory::MemoryManager& memory)
|
|||
Reset();
|
||||
}
|
||||
|
||||
void InstructionCache::Init(Memory::MemoryManager& memory)
|
||||
void InstructionCache::Init()
|
||||
{
|
||||
if (!m_config_callback_id)
|
||||
m_config_callback_id = Config::AddConfigChangedCallback([this] { RefreshConfig(); });
|
||||
RefreshConfig();
|
||||
|
||||
Cache::Init(memory);
|
||||
Cache::Init();
|
||||
}
|
||||
|
||||
void Cache::Store(Memory::MemoryManager& memory, u32 addr)
|
||||
void Cache::Store(u32 addr)
|
||||
{
|
||||
auto [set, way] = GetCache(memory, addr, true);
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
auto [set, way] = GetCache(addr, true);
|
||||
|
||||
if (way == 0xff)
|
||||
return;
|
||||
|
@ -142,8 +148,11 @@ void Cache::Store(Memory::MemoryManager& memory, u32 addr)
|
|||
modified[set] &= ~(1U << way);
|
||||
}
|
||||
|
||||
void Cache::FlushAll(Memory::MemoryManager& memory)
|
||||
void Cache::FlushAll()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
for (size_t set = 0; set < CACHE_SETS; set++)
|
||||
{
|
||||
for (size_t way = 0; way < CACHE_WAYS; way++)
|
||||
|
@ -156,9 +165,12 @@ void Cache::FlushAll(Memory::MemoryManager& memory)
|
|||
Reset();
|
||||
}
|
||||
|
||||
void Cache::Invalidate(Memory::MemoryManager& memory, u32 addr)
|
||||
void Cache::Invalidate(u32 addr)
|
||||
{
|
||||
auto [set, way] = GetCache(memory, addr, true);
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
auto [set, way] = GetCache(addr, true);
|
||||
|
||||
if (way == 0xff)
|
||||
return;
|
||||
|
@ -177,9 +189,12 @@ void Cache::Invalidate(Memory::MemoryManager& memory, u32 addr)
|
|||
}
|
||||
}
|
||||
|
||||
void Cache::Flush(Memory::MemoryManager& memory, u32 addr)
|
||||
void Cache::Flush(u32 addr)
|
||||
{
|
||||
auto [set, way] = GetCache(memory, addr, true);
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
auto [set, way] = GetCache(addr, true);
|
||||
|
||||
if (way == 0xff)
|
||||
return;
|
||||
|
@ -201,13 +216,16 @@ void Cache::Flush(Memory::MemoryManager& memory, u32 addr)
|
|||
}
|
||||
}
|
||||
|
||||
void Cache::Touch(Memory::MemoryManager& memory, u32 addr, bool store)
|
||||
void Cache::Touch(u32 addr, bool store)
|
||||
{
|
||||
GetCache(memory, addr, false);
|
||||
GetCache(addr, false);
|
||||
}
|
||||
|
||||
std::pair<u32, u32> Cache::GetCache(Memory::MemoryManager& memory, u32 addr, bool locked)
|
||||
std::pair<u32, u32> Cache::GetCache(u32 addr, bool locked)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
addr &= ~31;
|
||||
u32 set = (addr >> 5) & 0x7f;
|
||||
u32 way;
|
||||
|
@ -270,13 +288,16 @@ std::pair<u32, u32> Cache::GetCache(Memory::MemoryManager& memory, u32 addr, boo
|
|||
return {set, way};
|
||||
}
|
||||
|
||||
void Cache::Read(Memory::MemoryManager& memory, u32 addr, void* buffer, u32 len, bool locked)
|
||||
void Cache::Read(u32 addr, void* buffer, u32 len, bool locked)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
auto* value = static_cast<u8*>(buffer);
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
auto [set, way] = GetCache(memory, addr, locked);
|
||||
auto [set, way] = GetCache(addr, locked);
|
||||
|
||||
u32 offset_in_block = addr - (addr & ~31);
|
||||
u32 len_in_block = std::min<u32>(len, ((addr + 32) & ~31) - addr);
|
||||
|
@ -297,13 +318,16 @@ void Cache::Read(Memory::MemoryManager& memory, u32 addr, void* buffer, u32 len,
|
|||
}
|
||||
}
|
||||
|
||||
void Cache::Write(Memory::MemoryManager& memory, u32 addr, const void* buffer, u32 len, bool locked)
|
||||
void Cache::Write(u32 addr, const void* buffer, u32 len, bool locked)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
auto* value = static_cast<const u8*>(buffer);
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
auto [set, way] = GetCache(memory, addr, locked);
|
||||
auto [set, way] = GetCache(addr, locked);
|
||||
|
||||
u32 offset_in_block = addr - (addr & ~31);
|
||||
u32 len_in_block = std::min<u32>(len, ((addr + 32) & ~31) - addr);
|
||||
|
@ -325,8 +349,11 @@ void Cache::Write(Memory::MemoryManager& memory, u32 addr, const void* buffer, u
|
|||
}
|
||||
}
|
||||
|
||||
void Cache::DoState(Memory::MemoryManager& memory, PointerWrap& p)
|
||||
void Cache::DoState(PointerWrap& p)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
if (p.IsReadMode())
|
||||
{
|
||||
// Clear valid parts of the lookup tables (this is done instead of using fill(0xff) to avoid
|
||||
|
@ -375,26 +402,30 @@ void Cache::DoState(Memory::MemoryManager& memory, PointerWrap& p)
|
|||
}
|
||||
}
|
||||
|
||||
u32 InstructionCache::ReadInstruction(Memory::MemoryManager& memory,
|
||||
PowerPC::PowerPCState& ppc_state, u32 addr)
|
||||
{
|
||||
if (!HID0(ppc_state).ICE || m_disable_icache) // instruction cache is disabled
|
||||
return memory.Read_U32(addr);
|
||||
|
||||
u32 value;
|
||||
Read(memory, addr, &value, sizeof(value), HID0(ppc_state).ILOCK);
|
||||
return Common::swap32(value);
|
||||
}
|
||||
|
||||
void InstructionCache::Invalidate(Memory::MemoryManager& memory, JitInterface& jit_interface,
|
||||
u32 addr)
|
||||
u32 InstructionCache::ReadInstruction(u32 addr)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& ppc_state = system.GetPPCState();
|
||||
if (!HID0(ppc_state).ICE || m_disable_icache)
|
||||
return;
|
||||
|
||||
// Invalidates the whole set
|
||||
if (!HID0(ppc_state).ICE || m_disable_icache) // instruction cache is disabled
|
||||
return system.GetMemory().Read_U32(addr);
|
||||
|
||||
u32 value;
|
||||
Read(addr, &value, sizeof(value), HID0(ppc_state).ILOCK);
|
||||
return Common::swap32(value);
|
||||
}
|
||||
|
||||
void InstructionCache::Invalidate(u32 addr)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
// Per the 750cl manual, section 3.4.1.5 Instruction Cache Enabling/Disabling (page 137)
|
||||
// and section 3.4.2.6 Instruction Cache Block Invalidate (icbi) (page 140), the icbi
|
||||
// instruction always invalidates, even if the instruction cache is disabled or locked,
|
||||
// and it also invalidates all ways of the corresponding cache set, not just the way corresponding
|
||||
// to the given address.
|
||||
// (However, the icbi instruction's info on page 432 does not include this information)
|
||||
const u32 set = (addr >> 5) & 0x7f;
|
||||
for (size_t way = 0; way < 8; way++)
|
||||
{
|
||||
|
@ -411,6 +442,7 @@ void InstructionCache::Invalidate(Memory::MemoryManager& memory, JitInterface& j
|
|||
valid[set] = 0;
|
||||
modified[set] = 0;
|
||||
|
||||
// Also tell the JIT that the corresponding address has been invalidated
|
||||
system.GetJitInterface().InvalidateICacheLine(addr);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,16 +10,7 @@
|
|||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Config/Config.h"
|
||||
|
||||
class JitInterface;
|
||||
namespace Memory
|
||||
{
|
||||
class MemoryManager;
|
||||
}
|
||||
class PointerWrap;
|
||||
namespace PowerPC
|
||||
{
|
||||
struct PowerPCState;
|
||||
}
|
||||
|
||||
namespace PowerPC
|
||||
{
|
||||
|
@ -51,22 +42,22 @@ struct Cache
|
|||
std::vector<u8> lookup_table_ex{};
|
||||
std::vector<u8> lookup_table_vmem{};
|
||||
|
||||
void Store(Memory::MemoryManager& memory, u32 addr);
|
||||
void Invalidate(Memory::MemoryManager& memory, u32 addr);
|
||||
void Flush(Memory::MemoryManager& memory, u32 addr);
|
||||
void Touch(Memory::MemoryManager& memory, u32 addr, bool store);
|
||||
void Store(u32 addr);
|
||||
void Invalidate(u32 addr);
|
||||
void Flush(u32 addr);
|
||||
void Touch(u32 addr, bool store);
|
||||
|
||||
void FlushAll(Memory::MemoryManager& memory);
|
||||
void FlushAll();
|
||||
|
||||
std::pair<u32, u32> GetCache(Memory::MemoryManager& memory, u32 addr, bool locked);
|
||||
std::pair<u32, u32> GetCache(u32 addr, bool locked);
|
||||
|
||||
void Read(Memory::MemoryManager& memory, u32 addr, void* buffer, u32 len, bool locked);
|
||||
void Write(Memory::MemoryManager& memory, u32 addr, const void* buffer, u32 len, bool locked);
|
||||
void Read(u32 addr, void* buffer, u32 len, bool locked);
|
||||
void Write(u32 addr, const void* buffer, u32 len, bool locked);
|
||||
|
||||
void Init(Memory::MemoryManager& memory);
|
||||
void Init();
|
||||
void Reset();
|
||||
|
||||
void DoState(Memory::MemoryManager& memory, PointerWrap& p);
|
||||
void DoState(PointerWrap& p);
|
||||
};
|
||||
|
||||
struct InstructionCache : public Cache
|
||||
|
@ -77,10 +68,10 @@ struct InstructionCache : public Cache
|
|||
|
||||
InstructionCache() = default;
|
||||
~InstructionCache();
|
||||
u32 ReadInstruction(Memory::MemoryManager& memory, PowerPC::PowerPCState& ppc_state, u32 addr);
|
||||
void Invalidate(Memory::MemoryManager& memory, JitInterface& jit_interface, u32 addr);
|
||||
void Init(Memory::MemoryManager& memory);
|
||||
void Reset(JitInterface& jit_interface);
|
||||
u32 ReadInstruction(u32 addr);
|
||||
void Invalidate(u32 addr);
|
||||
void Init();
|
||||
void Reset();
|
||||
void RefreshConfig();
|
||||
};
|
||||
} // namespace PowerPC
|
||||
|
|
|
@ -55,8 +55,7 @@ void PairedSingle::SetPS1(double value)
|
|||
|
||||
static void InvalidateCacheThreadSafe(Core::System& system, u64 userdata, s64 cyclesLate)
|
||||
{
|
||||
system.GetPPCState().iCache.Invalidate(system.GetMemory(), system.GetJitInterface(),
|
||||
static_cast<u32>(userdata));
|
||||
system.GetPPCState().iCache.Invalidate(static_cast<u32>(userdata));
|
||||
}
|
||||
|
||||
PowerPCManager::PowerPCManager(Core::System& system)
|
||||
|
@ -100,16 +99,15 @@ void PowerPCManager::DoState(PointerWrap& p)
|
|||
p.Do(m_ppc_state.reserve);
|
||||
p.Do(m_ppc_state.reserve_address);
|
||||
|
||||
auto& memory = m_system.GetMemory();
|
||||
m_ppc_state.iCache.DoState(memory, p);
|
||||
m_ppc_state.dCache.DoState(memory, p);
|
||||
m_ppc_state.iCache.DoState(p);
|
||||
m_ppc_state.dCache.DoState(p);
|
||||
|
||||
if (p.IsReadMode())
|
||||
{
|
||||
if (!m_ppc_state.m_enable_dcache)
|
||||
{
|
||||
INFO_LOG_FMT(POWERPC, "Flushing data cache");
|
||||
m_ppc_state.dCache.FlushAll(memory);
|
||||
m_ppc_state.dCache.FlushAll();
|
||||
}
|
||||
|
||||
RoundingModeUpdated(m_ppc_state);
|
||||
|
@ -251,7 +249,7 @@ void PowerPCManager::RefreshConfig()
|
|||
if (old_enable_dcache && !m_ppc_state.m_enable_dcache)
|
||||
{
|
||||
INFO_LOG_FMT(POWERPC, "Flushing data cache");
|
||||
m_ppc_state.dCache.FlushAll(m_system.GetMemory());
|
||||
m_ppc_state.dCache.FlushAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,9 +265,11 @@ void PowerPCManager::Init(CPUCore cpu_core)
|
|||
Reset();
|
||||
|
||||
InitializeCPUCore(cpu_core);
|
||||
auto& memory = m_system.GetMemory();
|
||||
m_ppc_state.iCache.Init(memory);
|
||||
m_ppc_state.dCache.Init(memory);
|
||||
m_ppc_state.iCache.Init();
|
||||
m_ppc_state.dCache.Init();
|
||||
|
||||
if (Config::Get(Config::MAIN_ENABLE_DEBUGGING))
|
||||
m_breakpoints.ClearAllTemporary();
|
||||
}
|
||||
|
||||
void PowerPCManager::Reset()
|
||||
|
@ -279,7 +279,7 @@ void PowerPCManager::Reset()
|
|||
m_ppc_state.tlb = {};
|
||||
|
||||
ResetRegisters();
|
||||
m_ppc_state.iCache.Reset(m_system.GetJitInterface());
|
||||
m_ppc_state.iCache.Reset();
|
||||
m_ppc_state.dCache.Reset();
|
||||
}
|
||||
|
||||
|
@ -294,8 +294,7 @@ void PowerPCManager::ScheduleInvalidateCacheThreadSafe(u32 address)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_ppc_state.iCache.Invalidate(m_system.GetMemory(), m_system.GetJitInterface(),
|
||||
static_cast<u32>(address));
|
||||
m_ppc_state.iCache.Invalidate(static_cast<u32>(address));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue