diff options
author | bunnei <ericbunnie@gmail.com> | 2014-05-21 00:50:16 +0200 |
---|---|---|
committer | bunnei <ericbunnie@gmail.com> | 2014-05-21 00:50:16 +0200 |
commit | 49dc2ce8ac4fc37a008fa28e0771c8c74c576b05 (patch) | |
tree | 1640b629267273cb6afe73e7923833072ad55d7d /src/core/arm/interpreter | |
parent | renamed "syscall" module to "svc" (more accurate naming) (diff) | |
download | yuzu-49dc2ce8ac4fc37a008fa28e0771c8c74c576b05.tar yuzu-49dc2ce8ac4fc37a008fa28e0771c8c74c576b05.tar.gz yuzu-49dc2ce8ac4fc37a008fa28e0771c8c74c576b05.tar.bz2 yuzu-49dc2ce8ac4fc37a008fa28e0771c8c74c576b05.tar.lz yuzu-49dc2ce8ac4fc37a008fa28e0771c8c74c576b05.tar.xz yuzu-49dc2ce8ac4fc37a008fa28e0771c8c74c576b05.tar.zst yuzu-49dc2ce8ac4fc37a008fa28e0771c8c74c576b05.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/arm/interpreter/arm_interpreter.cpp | 36 | ||||
-rw-r--r-- | src/core/arm/interpreter/arm_interpreter.h | 12 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/core/arm/interpreter/arm_interpreter.cpp b/src/core/arm/interpreter/arm_interpreter.cpp index c21ff0464..b8c46cdfc 100644 --- a/src/core/arm/interpreter/arm_interpreter.cpp +++ b/src/core/arm/interpreter/arm_interpreter.cpp @@ -101,3 +101,39 @@ void ARM_Interpreter::ExecuteInstructions(int num_instructions) { m_state->NumInstrsToExecute = num_instructions; ARMul_Emulate32(m_state); } + +/** + * Saves the current CPU context + * @param ctx Thread context to save + * @todo Do we need to save Reg[15] and NextInstr? + */ +void ARM_Interpreter::SaveContext(ThreadContext& ctx) { + memcpy(ctx.cpu_registers, m_state->Reg, sizeof(ctx.cpu_registers)); + memcpy(ctx.fpu_registers, m_state->ExtReg, sizeof(ctx.fpu_registers)); + + ctx.sp = m_state->Reg[13]; + ctx.lr = m_state->Reg[14]; + ctx.pc = m_state->pc; + ctx.cpsr = m_state->Cpsr; + + ctx.fpscr = m_state->VFP[1]; + ctx.fpexc = m_state->VFP[2]; +} + +/** + * Loads a CPU context + * @param ctx Thread context to load + * @param Do we need to load Reg[15] and NextInstr? + */ +void ARM_Interpreter::LoadContext(const ThreadContext& ctx) { + memcpy(m_state->Reg, ctx.cpu_registers, sizeof(ctx.cpu_registers)); + memcpy(m_state->ExtReg, ctx.fpu_registers, sizeof(ctx.fpu_registers)); + + m_state->Reg[13] = ctx.sp; + m_state->Reg[14] = ctx.lr; + m_state->pc = ctx.pc; + m_state->Cpsr = ctx.cpsr; + + m_state->VFP[1] = ctx.fpscr; + m_state->VFP[2] = ctx.fpexc; +} diff --git a/src/core/arm/interpreter/arm_interpreter.h b/src/core/arm/interpreter/arm_interpreter.h index 474ba3e45..15240568c 100644 --- a/src/core/arm/interpreter/arm_interpreter.h +++ b/src/core/arm/interpreter/arm_interpreter.h @@ -60,6 +60,18 @@ public: */ u64 GetTicks() const; + /** + * Saves the current CPU context + * @param ctx Thread context to save + */ + void SaveContext(ThreadContext& ctx); + + /** + * Loads a CPU context + * @param ctx Thread context to load + */ + void LoadContext(const ThreadContext& ctx); + protected: /** |