Fix external exception processing.

This commit is contained in:
Maxim Poliakovski 2022-01-10 17:27:27 +01:00
parent d4ecb77b24
commit aefc66d118
3 changed files with 13 additions and 5 deletions

View File

@ -329,6 +329,7 @@ extern void ppc_mmu_init(uint32_t cpu_version);
[[noreturn]] void ppc_illegalop();
[[noreturn]] void ppc_fpu_off();
void ppc_ext_int();
//void ppc_opcode4();
void ppc_opcode16();
@ -364,7 +365,7 @@ void ppc_changecrf0(uint32_t set_result);
void ppc_fp_changecrf1();
/* Exception handlers. */
[[noreturn]] void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits);
void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits);
[[noreturn]] void dbg_exception_handler(Except_Type exception_type, uint32_t srr1_bits);
// MEMORY DECLARATIONS

View File

@ -29,8 +29,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
jmp_buf exc_env; /* Global exception environment. */
[[noreturn]] void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
grab_exception = true;
void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
#ifdef CPU_PROFILING
exceptions_processed++;
#endif
@ -61,7 +60,7 @@ jmp_buf exc_env; /* Global exception environment. */
break;
case Except_Type::EXC_EXT_INT:
ppc_state.spr[SPR::SRR0] = ppc_next_instruction_address;
ppc_state.spr[SPR::SRR0] = ppc_state.pc & 0xFFFFFFFC;
ppc_next_instruction_address = 0x0500;
break;
@ -118,7 +117,9 @@ jmp_buf exc_env; /* Global exception environment. */
mmu_change_mode();
longjmp(exc_env, 2); /* return to the main execution loop. */
if (exception_type != Except_Type::EXC_EXT_INT) {
longjmp(exc_env, 2); /* return to the main execution loop. */
}
}

View File

@ -186,6 +186,12 @@ PPCOpcode SubOpcode63Grabber[1024] = { ppc_illegalop };
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::FPU_OFF);
}
void ppc_ext_int() {
if (ppc_state.msr & 0x8000) {
ppc_exception_handler(Except_Type::EXC_EXT_INT, 0);
}
}
/** Opcode decoding functions. */
void ppc_opcode16() {