kstenerud / Musashi

Motorola 680x0 emulator written in C
427 stars 96 forks source link

fix for Freebee emulator #78

Closed agentbooth closed 3 years ago

agentbooth commented 3 years ago

Hi Karl. I have been helping Phil Pemberton with his UNIX PC emulator Freebee (https://github.com/philpem/freebee).

On the 68010-based UNIX PC, from what I can tell, it is valid to encounter a page fault (bus error) during the exception handling of a prior bus error/PF. This presents a problem currently in m68ki_exception_bus_error(). This "double bus error" will halt the system. I believe the proper handling is that a double bus error is only an issue if it occurs during setup of the stack frame -- which in Musashi occurs within m68ki_exception_bus_error() so I believe should never occur.

I looked at the handling in MAME, they seem to follow this reasoning, that the double bus error or double address error only can happen within the window of setting up the stack frame. I attempted to mirror their handling in this pull request.

An alternative would be to remove the check entirely as the stack frame is setup in m68ki_exception_bus_error().

I don't know the details of how to handle the address error exception, but I have mirrored what MAME does.

I am by no means an expert on any of this! Just trying to fix our problem in Freebee.

kstenerud commented 3 years ago

Oh wow I had no idea that it was such a short window for the lockup path! Nicely found!!