diff --git a/cpu/ppc/ppcemu.h b/cpu/ppc/ppcemu.h index 3b97f85..989ba58 100644 --- a/cpu/ppc/ppcemu.h +++ b/cpu/ppc/ppcemu.h @@ -302,8 +302,8 @@ void ppc_fp_changecrf1(); // MEMORY DECLARATIONS extern MemCtrlBase* mem_ctrl_instance; -//typedef std::function CtxSyncCallback; extern void add_ctx_sync_action(const std::function &); +extern void do_ctx_sync(void); // The functions used by the PowerPC processor namespace dppc_interpreter { diff --git a/cpu/ppc/ppcexceptions.cpp b/cpu/ppc/ppcexceptions.cpp index 015da7f..cd419b3 100644 --- a/cpu/ppc/ppcexceptions.cpp +++ b/cpu/ppc/ppcexceptions.cpp @@ -110,6 +110,12 @@ jmp_buf exc_env; /* Global exception environment. */ ppc_next_instruction_address |= 0xFFF00000; } + // perform context synchronization for recoverable exceptions + if (exception_type != Except_Type::EXC_MACHINE_CHECK && + exception_type != Except_Type::EXC_SYSTEM_RESET) { + do_ctx_sync(); + } + mmu_change_mode(); longjmp(exc_env, 2); /* return to the main execution loop. */ diff --git a/cpu/ppc/ppcopcodes.cpp b/cpu/ppc/ppcopcodes.cpp index 1a597eb..99cd524 100644 --- a/cpu/ppc/ppcopcodes.cpp +++ b/cpu/ppc/ppcopcodes.cpp @@ -1302,6 +1302,8 @@ void dppc_interpreter::ppc_rfi() { ppc_state.msr = (new_msr_val | new_srr1_val) & 0xFFFBFFFFUL; ppc_next_instruction_address = ppc_state.spr[SPR::SRR0] & 0xFFFFFFFCUL; + do_ctx_sync(); // RFI is context synchronizing + mmu_change_mode(); grab_return = true; @@ -1309,6 +1311,7 @@ void dppc_interpreter::ppc_rfi() { } void dppc_interpreter::ppc_sc() { + do_ctx_sync(); // SC is context synchronizing! ppc_exception_handler(Except_Type::EXC_SYSCALL, 0x20000); }