fix(memory): ignore CPU and DMA writes to unused I/O addresses
Stores to I/O addresses with no register returned Unmapped and stopped the machine. Hardware ignores them. Emulated writes there now pay their bus cost and change nothing; host writes stay strict. The unmodeled internal memory control register at 0x04xx0800 and all unused I/O reads remain diagnostics. Rollback tests that used unused I/O as their failing word now run the block on to a register that rejects the stored value: SIOMULTI2 outside multiplayer mode, an RCNT GPIO serial IRQ, or 64-sample wave playback. Where no reachable register can fail (JOYSTAT, POSTFLG/HALTCNT, IME, DMA3CNT), the test now checks that the block commits and the unused word is ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HhfHfHEuzv2AUTd6erW1gU
This commit is contained in:
parent
b535c08313
commit
20176716d9
16 changed files with 166 additions and 92 deletions
|
|
@ -168,10 +168,27 @@ fn invalid_word_and_block_writes_do_not_leave_a_partial_external_start() {
|
|||
assert_eq!(bus.read16(SIOCNT).unwrap(), 0x5084);
|
||||
assert_eq!(bus.read16(SIODATA8).unwrap(), 0xab);
|
||||
|
||||
let mut machine = prepared(false, 0xe8a00006, 0x00ab5080); // STMIA r0!,{r1,r2}; second word unmapped.
|
||||
// STMIA r0!,{r1-r4}: SIOCNT, ignored padding, KEYCNT, then RCNT enabling a GPIO serial IRQ.
|
||||
let code = [
|
||||
0xe59f_000c_u32,
|
||||
0xe59f_100c,
|
||||
0xe59f_400c,
|
||||
0xe8a0_001e,
|
||||
0xeaff_fffe,
|
||||
SIOCNT,
|
||||
0x00ab_5080,
|
||||
0x0000_8100,
|
||||
];
|
||||
let mut bus = Memory::new(code.into_iter().flat_map(u32::to_le_bytes).collect()).unwrap();
|
||||
let mut cpu = Cpu::new(ROM_START);
|
||||
for _ in 0..3 {
|
||||
cpu.step(&mut bus).unwrap();
|
||||
}
|
||||
bus.write16(SIOCNT, 0x1003).unwrap();
|
||||
let mut machine = Machine::new(cpu, bus);
|
||||
let before = machine.cpu().clone();
|
||||
let error = machine.step().unwrap_err();
|
||||
assert!(error.to_string().contains("unmapped memory at 0x0400012c"));
|
||||
assert!(error.to_string().contains("0x04000135"), "{error}");
|
||||
assert_eq!(machine.cpu(), &before);
|
||||
assert_eq!(machine.cycles(), 0);
|
||||
assert_eq!(machine.memory().read16(SIOCNT).unwrap(), 0x1007);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue