summaryrefslogtreecommitdiff
path: root/src/core/arm/interpreter
diff options
context:
space:
mode:
authorGravatar bunnei2014-05-20 18:50:16 -0400
committerGravatar bunnei2014-05-20 18:50:16 -0400
commit49dc2ce8ac4fc37a008fa28e0771c8c74c576b05 (patch)
tree1640b629267273cb6afe73e7923833072ad55d7d /src/core/arm/interpreter
parentrenamed "syscall" module to "svc" (more accurate naming) (diff)
downloadyuzu-49dc2ce8ac4fc37a008fa28e0771c8c74c576b05.tar.gz
yuzu-49dc2ce8ac4fc37a008fa28e0771c8c74c576b05.tar.xz
yuzu-49dc2ce8ac4fc37a008fa28e0771c8c74c576b05.zip
ARM_Interface: added SaveContext and LoadContext functions for HLE thread switching
Diffstat (limited to 'src/core/arm/interpreter')
-rw-r--r--src/core/arm/interpreter/arm_interpreter.cpp36
-rw-r--r--src/core/arm/interpreter/arm_interpreter.h12
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) {
101 m_state->NumInstrsToExecute = num_instructions; 101 m_state->NumInstrsToExecute = num_instructions;
102 ARMul_Emulate32(m_state); 102 ARMul_Emulate32(m_state);
103} 103}
104
105/**
106 * Saves the current CPU context
107 * @param ctx Thread context to save
108 * @todo Do we need to save Reg[15] and NextInstr?
109 */
110void ARM_Interpreter::SaveContext(ThreadContext& ctx) {
111 memcpy(ctx.cpu_registers, m_state->Reg, sizeof(ctx.cpu_registers));
112 memcpy(ctx.fpu_registers, m_state->ExtReg, sizeof(ctx.fpu_registers));
113
114 ctx.sp = m_state->Reg[13];
115 ctx.lr = m_state->Reg[14];
116 ctx.pc = m_state->pc;
117 ctx.cpsr = m_state->Cpsr;
118
119 ctx.fpscr = m_state->VFP[1];
120 ctx.fpexc = m_state->VFP[2];
121}
122
123/**
124 * Loads a CPU context
125 * @param ctx Thread context to load
126 * @param Do we need to load Reg[15] and NextInstr?
127 */
128void ARM_Interpreter::LoadContext(const ThreadContext& ctx) {
129 memcpy(m_state->Reg, ctx.cpu_registers, sizeof(ctx.cpu_registers));
130 memcpy(m_state->ExtReg, ctx.fpu_registers, sizeof(ctx.fpu_registers));
131
132 m_state->Reg[13] = ctx.sp;
133 m_state->Reg[14] = ctx.lr;
134 m_state->pc = ctx.pc;
135 m_state->Cpsr = ctx.cpsr;
136
137 m_state->VFP[1] = ctx.fpscr;
138 m_state->VFP[2] = ctx.fpexc;
139}
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:
60 */ 60 */
61 u64 GetTicks() const; 61 u64 GetTicks() const;
62 62
63 /**
64 * Saves the current CPU context
65 * @param ctx Thread context to save
66 */
67 void SaveContext(ThreadContext& ctx);
68
69 /**
70 * Loads a CPU context
71 * @param ctx Thread context to load
72 */
73 void LoadContext(const ThreadContext& ctx);
74
63protected: 75protected:
64 76
65 /** 77 /**