Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interrupt handling in DOS 1 mode #107

Merged
merged 1 commit into from
Aug 31, 2022

Conversation

Konamiman
Copy link
Owner

@Konamiman Konamiman commented Jul 15, 2022

Prerrequisite for understanding this issue: Read how interrupts and HOKSAV work in MSX-DOS.

In MSX-DOS 1 mode Nextor was incorrectly invoking SETINT and PRVINT, 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 of SETINT and PRVINT 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:

image

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:

  1. H.TIMI (FD9Fh)
  2. The Nextor interrupt routine (address is at FDA1h)
  3. 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.

- In DOS 1 mode, save old interrupt and jump to it the same way
  it's done in normal mode, instead of trying to use the DOS 1 style
  SETINT and PRVINT routines.
- Remove the useless SETINT and PRVINT routines (these are intended
  to be called by DOS 1 and DOS 2 drivers, but in Nextor the driver's
  interrupt routine is called explicitly by the kernel)
@Konamiman Konamiman force-pushed the fix/interrupt-handling-in-dos1 branch from bde7014 to 18ba22d Compare July 15, 2022 20:35
@Konamiman Konamiman changed the base branch from v2.1 to v2.1.1 July 15, 2022 20:40
@Konamiman Konamiman added this to the v2.1.1 final milestone Jul 15, 2022
@Konamiman Konamiman self-assigned this Jul 15, 2022
@Konamiman Konamiman marked this pull request as ready for review July 16, 2022 16:02
@Konamiman Konamiman merged commit a279d26 into v2.1.1 Aug 31, 2022
@Konamiman Konamiman deleted the fix/interrupt-handling-in-dos1 branch August 31, 2022 11:10
@Konamiman Konamiman mentioned this pull request Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nextor IDE driver/BIOS causes a weird effect when CF card not present in IDE device
1 participant