A GameCube/Wii emulator and debugger written in Rust.
refactor syscall
Layle7447db495083
diff --git a/crates/gekko/src/cpu/interpreter/system.rs b/crates/gekko/src/cpu/interpreter/system.rsindex 2a4c777..fd39f5b 100644--- a/crates/gekko/src/cpu/interpreter/system.rs+++ b/crates/gekko/src/cpu/interpreter/system.rs@@ -67,27 +67,5 @@ pub fn mftb(ctx: &mut crate::gekko::Gekko, instr: crate::cpu::semantics::Instrucpub fn nop<const OP: u32>(_ctx: &mut crate::gekko::Gekko, _instr: crate::cpu::semantics::Instruction) {}pub fn sc(ctx: &mut crate::gekko::Gekko, _instr: crate::cpu::semantics::Instruction) {- let base: u32 = if ctx.cpu.msr.exception_prefix() { 0xFFF0_0000 } else { 0 };-- ctx.cpu.spr.srr0 = Srr0::from(ctx.cpu.cia.wrapping_add(4));- ctx.cpu.spr.srr1 = chapa::extract_bits!(ctx.cpu.msr; 0, 5..=9, 16..=31).raw();-- ctx.cpu.msr = ctx- .cpu- .msr- .with_pow(false)- .with_fp(false)- .with_be(false)- .with_dr(false)- .with_fe1(false)- .with_pm(false)- .with_ee(false)- .with_fe0(false)- .with_ri(false)- .with_pr(false)- .with_se(false)- .with_ir(false)- .with_le(ctx.cpu.msr.ile());-- ctx.cpu.nia = base | irq::IRQ_SYSTEM_CALL;+ ctx.cause_syscall_interrupt();}diff --git a/crates/gekko/src/cpu/irq.rs b/crates/gekko/src/cpu/irq.rsindex d9f999f..d57124d 100644--- a/crates/gekko/src/cpu/irq.rs+++ b/crates/gekko/src/cpu/irq.rs@@ -49,4 +49,30 @@ impl Gekko {tracing::debug!(addr = format!("{:08X}", self.cpu.pc), "IRQ triggered");}++ pub fn cause_syscall_interrupt(&mut self) {+ let base: u32 = if self.cpu.msr.exception_prefix() { 0xFFF0_0000 } else { 0 };++ self.cpu.spr.srr0 = Srr0::from(self.cpu.cia.wrapping_add(4));+ self.cpu.spr.srr1 = chapa::extract_bits!(self.cpu.msr; 0, 5..=9, 16..=31).raw();++ self.cpu.msr = self+ .cpu+ .msr+ .with_pow(false)+ .with_fp(false)+ .with_be(false)+ .with_dr(false)+ .with_fe1(false)+ .with_pm(false)+ .with_ee(false)+ .with_fe0(false)+ .with_ri(false)+ .with_pr(false)+ .with_se(false)+ .with_ir(false)+ .with_le(self.cpu.msr.ile());++ self.cpu.nia = base | IRQ_SYSTEM_CALL;+ }}