diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index ccd43f431..028a9e306 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h @@ -4,6 +4,7 @@ #pragma once +#include #include "common/common_types.h" #include "core/arm/skyeye_common/arm_regformat.h" #include "core/arm/skyeye_common/vfp/asm_vfp.h" @@ -41,6 +42,13 @@ public: /// Clear all instruction cache virtual void ClearInstructionCache() = 0; + /** + * Invalidate the code cache at a range of addresses. + * @param start_address The starting address of the range to invalidate. + * @param length The length (in bytes) of the range to invalidate. + */ + virtual void InvalidateCacheRange(u32 start_address, size_t length) = 0; + /** * Set the Program Counter to an address * @param addr Address to set PC to diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 0a0b91590..39e4ef675 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp @@ -176,3 +176,7 @@ void ARM_Dynarmic::PrepareReschedule() { void ARM_Dynarmic::ClearInstructionCache() { jit->ClearCache(); } + +void ARM_Dynarmic::InvalidateCacheRange(u32 start_address, size_t length) { + jit->InvalidateCacheRange(start_address, length); +} diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index 834dc989e..c9e88a267 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h @@ -36,6 +36,7 @@ public: void ExecuteInstructions(int num_instructions) override; void ClearInstructionCache() override; + void InvalidateCacheRange(u32 start_address, size_t length) override; private: std::unique_ptr jit; diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp index 81f9bf99e..f543cf633 100644 --- a/src/core/arm/dyncom/arm_dyncom.cpp +++ b/src/core/arm/dyncom/arm_dyncom.cpp @@ -25,6 +25,11 @@ void ARM_DynCom::ClearInstructionCache() { trans_cache_buf_top = 0; } +void ARM_DynCom::InvalidateCacheRange(u32, size_t) { + // Just clear the whole cache, we don't gain much from partial invalidations. + ClearInstructionCache(); +} + void ARM_DynCom::SetPC(u32 pc) { state->Reg[15] = pc; } diff --git a/src/core/arm/dyncom/arm_dyncom.h b/src/core/arm/dyncom/arm_dyncom.h index 62c174f3c..a20aa3afa 100644 --- a/src/core/arm/dyncom/arm_dyncom.h +++ b/src/core/arm/dyncom/arm_dyncom.h @@ -16,6 +16,7 @@ public: ~ARM_DynCom(); void ClearInstructionCache() override; + void InvalidateCacheRange(u32 start_address, size_t length) override; void SetPC(u32 pc) override; u32 GetPC() const override;