From 78b74101b0dc6cb7e2dc8424928e34138423c116 Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 29 Oct 2011 17:21:20 +1100 Subject: [PATCH] Added code to invalidate the JIT cache on dcbf. This fixes Monster House and Scooby Doo: Mystery Mayhem. --- Source/Core/Core/Src/HW/MemmapFunctions.cpp | 4 ++-- .../PowerPC/Interpreter/Interpreter_LoadStore.cpp | 14 +++++++++++--- .../Core/Core/Src/PowerPC/Jit64/Jit64_Tables.cpp | 10 +++++----- Source/Core/Core/Src/PowerPC/Jit64IL/JitIL.cpp | 2 +- .../Core/Core/Src/PowerPC/Jit64IL/JitIL_Tables.cpp | 10 +++++----- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Source/Core/Core/Src/HW/MemmapFunctions.cpp b/Source/Core/Core/Src/HW/MemmapFunctions.cpp index 993a3aabf1..7e3f78616d 100644 --- a/Source/Core/Core/Src/HW/MemmapFunctions.cpp +++ b/Source/Core/Core/Src/HW/MemmapFunctions.cpp @@ -273,8 +273,7 @@ inline void WriteToHardware(u32 em_address, const T data, u32 effective_address, ((em_address & 0xF0000000) == 0xD0000000) || ((em_address & 0xF0000000) == 0x10000000)) { - // Should we invalidate jit blocks in exram? - //PowerPC::ppcState.iCache.InvalidateBlock(em_address); + PowerPC::ppcState.iCache.InvalidateBlock(em_address); *(T*)&m_pEXRAM[em_address & EXRAM_MASK] = bswap(data); return; } @@ -287,6 +286,7 @@ inline void WriteToHardware(u32 em_address, const T data, u32 effective_address, (bFakeVMEM && ((em_address &0xF0000000) == 0x40000000))) { // fake VMEM + PowerPC::ppcState.iCache.InvalidateBlock(em_address); *(T*)&m_pFakeVMEM[em_address & FAKEVMEM_MASK] = bswap(data); } else diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStore.cpp b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStore.cpp index 81346b3ae6..1133f348e4 100644 --- a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStore.cpp +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStore.cpp @@ -363,15 +363,23 @@ void Interpreter::dcbf(UGeckoInstruction _inst) { NPC = PC + 12; }*/ + // Invalidate the icache on dcbf + if (jit) + { + u32 address = Helper_Get_EA_X(_inst); + jit->GetBlockCache()->InvalidateICache(address & ~0x1f); + } } void Interpreter::dcbi(UGeckoInstruction _inst) { - // Removes a block from data cache. Since we don't emulate the data cache, we don't need to do anything. - // Seen used during initialization. - u32 address = Helper_Get_EA_X(_inst); + // Removes a block from data cache. Since we don't emulate the data cache, we don't need to do anything to the data cache + // However, we invalidate the icache on dcbi if (jit) + { + u32 address = Helper_Get_EA_X(_inst); jit->GetBlockCache()->InvalidateICache(address & ~0x1f); + } } void Interpreter::dcbst(UGeckoInstruction _inst) diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit64_Tables.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit64_Tables.cpp index 1632a76796..c366617dfa 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit64_Tables.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit64_Tables.cpp @@ -210,12 +210,12 @@ static GekkoOPTemplate table31[] = {824, &Jit64::srawix}, //"srawix", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, {24, &Jit64::slwx}, //"slwx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, - {54, &Jit64::Default}, //"dcbst", OPTYPE_DCACHE, 0, 4}}, - {86, &Jit64::DoNothing}, //"dcbf", OPTYPE_DCACHE, 0, 4}}, - {246, &Jit64::Default}, //"dcbtst", OPTYPE_DCACHE, 0, 1}}, - {278, &Jit64::Default}, //"dcbt", OPTYPE_DCACHE, 0, 1}}, + {54, &Jit64::DoNothing}, //"dcbst", OPTYPE_DCACHE, 0, 4}}, + {86, &Jit64::Default}, //"dcbf", OPTYPE_DCACHE, 0, 4}}, + {246, &Jit64::DoNothing}, //"dcbtst", OPTYPE_DCACHE, 0, 1}}, + {278, &Jit64::DoNothing}, //"dcbt", OPTYPE_DCACHE, 0, 1}}, {470, &Jit64::Default}, //"dcbi", OPTYPE_DCACHE, 0, 4}}, - {758, &Jit64::Default}, //"dcba", OPTYPE_DCACHE, 0, 4}}, + {758, &Jit64::DoNothing}, //"dcba", OPTYPE_DCACHE, 0, 4}}, {1014, &Jit64::dcbz}, //"dcbz", OPTYPE_DCACHE, 0, 4}}, //load word diff --git a/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL.cpp b/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL.cpp index 4110c37f96..75755de5cb 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL.cpp @@ -494,7 +494,7 @@ void JitIL::Trace() } #endif - NOTICE_LOG(DYNA_REC, "JITIL PC: %08x SRR0: %08x SRR1: %08x CRfast: %02x%02x%02x%02x%02x%02x%02x%02x FPSCR: %08x MSR: %08x LR: %08x %s %s", + DEBUG_LOG(DYNA_REC, "JITIL PC: %08x SRR0: %08x SRR1: %08x CRfast: %02x%02x%02x%02x%02x%02x%02x%02x FPSCR: %08x MSR: %08x LR: %08x %s %s", PC, SRR0, SRR1, PowerPC::ppcState.cr_fast[0], PowerPC::ppcState.cr_fast[1], PowerPC::ppcState.cr_fast[2], PowerPC::ppcState.cr_fast[3], PowerPC::ppcState.cr_fast[4], PowerPC::ppcState.cr_fast[5], PowerPC::ppcState.cr_fast[6], PowerPC::ppcState.cr_fast[7], PowerPC::ppcState.fpscr, PowerPC::ppcState.msr, PowerPC::ppcState.spr[8], regs, fregs); diff --git a/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL_Tables.cpp b/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL_Tables.cpp index f34f100657..bcfea0a07b 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL_Tables.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL_Tables.cpp @@ -212,12 +212,12 @@ static GekkoOPTemplate table31[] = {824, &JitIL::srawix}, //"srawix", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, {24, &JitIL::slwx}, //"slwx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, - {54, &JitIL::Default}, //"dcbst", OPTYPE_DCACHE, 0, 4}}, - {86, &JitIL::DoNothing}, //"dcbf", OPTYPE_DCACHE, 0, 4}}, - {246, &JitIL::Default}, //"dcbtst", OPTYPE_DCACHE, 0, 1}}, - {278, &JitIL::Default}, //"dcbt", OPTYPE_DCACHE, 0, 1}}, + {54, &JitIL::DoNothing}, //"dcbst", OPTYPE_DCACHE, 0, 4}}, + {86, &JitIL::Default}, //"dcbf", OPTYPE_DCACHE, 0, 4}}, + {246, &JitIL::DoNothing}, //"dcbtst", OPTYPE_DCACHE, 0, 1}}, + {278, &JitIL::DoNothing}, //"dcbt", OPTYPE_DCACHE, 0, 1}}, {470, &JitIL::Default}, //"dcbi", OPTYPE_DCACHE, 0, 4}}, - {758, &JitIL::Default}, //"dcba", OPTYPE_DCACHE, 0, 4}}, + {758, &JitIL::DoNothing}, //"dcba", OPTYPE_DCACHE, 0, 4}}, {1014, &JitIL::dcbz}, //"dcbz", OPTYPE_DCACHE, 0, 4}}, //load word {23, &JitIL::lXzx}, //"lwzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}},