HLE/RO: Clear the dyncom instruction cache when we load a CRO

This commit is contained in:
Subv 2015-12-28 13:55:49 -05:00
parent a8d0bffcf7
commit 2ace21b4db
4 changed files with 16 additions and 0 deletions

View File

@ -31,6 +31,8 @@ public:
Run(1); Run(1);
} }
virtual void ClearInstructionCache() { }
/** /**
* Set the Program Counter to an address * Set the Program Counter to an address
* @param addr Address to set PC to * @param addr Address to set PC to

View File

@ -24,6 +24,10 @@ ARM_DynCom::ARM_DynCom(PrivilegeMode initial_mode) {
ARM_DynCom::~ARM_DynCom() { ARM_DynCom::~ARM_DynCom() {
} }
void ARM_DynCom::ClearInstructionCache() {
state->instruction_cache.clear();
}
void ARM_DynCom::SetPC(u32 pc) { void ARM_DynCom::SetPC(u32 pc) {
state->Reg[15] = pc; state->Reg[15] = pc;
} }

View File

@ -21,6 +21,8 @@ public:
ARM_DynCom(PrivilegeMode initial_mode); ARM_DynCom(PrivilegeMode initial_mode);
~ARM_DynCom(); ~ARM_DynCom();
void ClearInstructionCache() override;
void SetPC(u32 pc) override; void SetPC(u32 pc) override;
u32 GetPC() const override; u32 GetPC() const override;
u32 GetReg(int index) const override; u32 GetReg(int index) const override;

View File

@ -4,6 +4,8 @@
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/core.h"
#include "core/arm/arm_interface.h"
#include "core/hle/hle.h" #include "core/hle/hle.h"
#include "core/hle/service/ldr_ro.h" #include "core/hle/service/ldr_ro.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
@ -837,6 +839,9 @@ static ResultCode LoadCRO(u32 base, u32 size, u8* cro, u32 data_section0, u32 da
file.WriteBytes(header, header->file_size); file.WriteBytes(header, header->file_size);
file.Close(); file.Close();
// Clear the instruction cache
Core::g_app_core->ClearInstructionCache();
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@ -973,6 +978,9 @@ static void LoadExeCRO(Service::Interface* self) {
ResultCode result = LoadCRO(address, size, Memory::GetPointer(address), cmd_buff[4], cmd_buff[7], false); ResultCode result = LoadCRO(address, size, Memory::GetPointer(address), cmd_buff[4], cmd_buff[7], false);
if (result.IsError())
LOG_CRITICAL(Service_LDR, "Error when loading CRO %08X", result.raw);
cmd_buff[0] = IPC::MakeHeader(4, 2, 0); cmd_buff[0] = IPC::MakeHeader(4, 2, 0);
cmd_buff[1] = result.raw; cmd_buff[1] = result.raw;
cmd_buff[2] = 0; cmd_buff[2] = 0;