ARM_Interface: added SaveContext and LoadContext functions for HLE thread switching
This commit is contained in:
parent
143bba2045
commit
49dc2ce8ac
4 changed files with 65 additions and 37 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue