Fix interrupt handling in DOS 1 mode #107
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerrequisite for understanding this issue: Read how interrupts and HOKSAV work in MSX-DOS.
In MSX-DOS 1 mode Nextor was incorrectly invoking
SETINT
andPRVINT
, which is something that don't make any sense since these routines are intended to be invoked by the drivers themselves but in the Nextor world disk drivers provide their interrupt routines at a fixed address that is invoked by the kernel.Combined with the fact that a Nextor driver not having any available device at boot time (e.g. removable device with no media inserted) will end up not having an entry in
DRVTBL
, this caused the interrupt service routine of drivers in MSX-DOS ROMs to never be executed, with nasty effects (e.g. FDD motor never going off).The fix consists of just storing the previous value of
H.TIMI
in an internal buffer and jumping to it at the end of the interrupt processing when booting in DOS 1 mode as well (the same thing was being done already by MSX-DOS 2 and by Nextor when booting in normal mode), this ensures that all the interrupts routines in all drivers are properly executed. And while we're at it, the code ofSETINT
andPRVINT
has been removed since it's completely useless in Nextor (as Nextor drivers will never invoke them).How to test
You can test this fix in an emulator using any Nextor kernel (the Sunrise IDE one will do) and a Philips NMS8280 with a duplicate disk controller, see for example this configuration in blueMSX:
The order of the slots (Nextor before the FDDs or the other way around) shouldn't matter.
With this setup and making sure that you don't have any volume actually attached to the Nextor device (e.g. in blueMSX go to "Hard disk" - "Sunrise primary", then "Sunrise secondary", and "eject" if there's something set) and that you force booting in MSX-DOS 1 mode (by e.g. pressing the "1" key while booting) you can set breakpoints in the following locations and verify that all are hit:
H.TIMI
(FD9Fh
)FDA1h
)7900h
, this corresponds to the interrupt routine of the FDD and should be hit twice, one for each FDD controller slot.Without the fix, only the first two will be hit.
Closes #64.