Implement all required context-synchronizing events.

This commit is contained in:
Maxim Poliakovski 2021-10-13 20:58:09 +02:00
parent 7c47b9c1e7
commit e53296f7a9
3 changed files with 10 additions and 1 deletions

View File

@ -302,8 +302,8 @@ void ppc_fp_changecrf1();
// MEMORY DECLARATIONS // MEMORY DECLARATIONS
extern MemCtrlBase* mem_ctrl_instance; extern MemCtrlBase* mem_ctrl_instance;
//typedef std::function<void()> CtxSyncCallback;
extern void add_ctx_sync_action(const std::function<void()> &); extern void add_ctx_sync_action(const std::function<void()> &);
extern void do_ctx_sync(void);
// The functions used by the PowerPC processor // The functions used by the PowerPC processor
namespace dppc_interpreter { namespace dppc_interpreter {

View File

@ -110,6 +110,12 @@ jmp_buf exc_env; /* Global exception environment. */
ppc_next_instruction_address |= 0xFFF00000; 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(); mmu_change_mode();
longjmp(exc_env, 2); /* return to the main execution loop. */ longjmp(exc_env, 2); /* return to the main execution loop. */

View File

@ -1302,6 +1302,8 @@ void dppc_interpreter::ppc_rfi() {
ppc_state.msr = (new_msr_val | new_srr1_val) & 0xFFFBFFFFUL; ppc_state.msr = (new_msr_val | new_srr1_val) & 0xFFFBFFFFUL;
ppc_next_instruction_address = ppc_state.spr[SPR::SRR0] & 0xFFFFFFFCUL; ppc_next_instruction_address = ppc_state.spr[SPR::SRR0] & 0xFFFFFFFCUL;
do_ctx_sync(); // RFI is context synchronizing
mmu_change_mode(); mmu_change_mode();
grab_return = true; grab_return = true;
@ -1309,6 +1311,7 @@ void dppc_interpreter::ppc_rfi() {
} }
void dppc_interpreter::ppc_sc() { void dppc_interpreter::ppc_sc() {
do_ctx_sync(); // SC is context synchronizing!
ppc_exception_handler(Except_Type::EXC_SYSCALL, 0x20000); ppc_exception_handler(Except_Type::EXC_SYSCALL, 0x20000);
} }