washingtondc-emu / washingtondc

Open-source Sega Dreamcast emulator
http://www.washemu.org
GNU General Public License v3.0
240 stars 7 forks source link

researching hardware bug: spurious IRQ generation from Hollywood #81

Open snickerbockers opened 4 years ago

snickerbockers commented 4 years ago

It seems that when writing to certain hollywood interrupt control registers, the register must be read from or written to with the same value twice after the first write.

ISTNRM (0xa05f6900) is one such register. This probably also applies to ISTEXT, ISTERR, and maybe the IML* registers as well.

Failure to access the register multiple times after the initial write can cause the initial write to not take effect. It seems that the initial write does not fail to change the value of the register, but it does fail to update the hollywood's interrupt control state.

In the specific situation where I discovered this bug, I was clearing bit 19 (CH2 DMA) in ISTNRM by writing to it from an interrupt handler, and I found that immediately after issuing the rte instruction, the interrupt handler was re-entered a second time even though ISTNRM showed that there were no exceptions being generated. The interrupt handler was not re-entered a third time because the second interrupt handler read from the ISTNRM register.

This bug probably effects many homebrew titles and official releases. Since hollywood multiplexes most interrupts onto a single IRQ line, real code would have to filter out spurious interrupts based on ISTNRM and that probably prevents this bug from having a noticeable effect since ISTNRM does not show any new interrupts being generated.