bjt42 / softmpu

An MPU-401 emulation TSR for DOS
http://bjt42.github.io/softmpu/
GNU General Public License v2.0
105 stars 15 forks source link

Remove interrupt disabling from QPI port trapping path #25

Open karcherm opened 2 years ago

karcherm commented 2 years ago

The QEMM QPI specification explicitly states that the handler is entered with interrupts disabled (and the original IF by the caller is passed as bit 9 in CX). This is the relevant snippet of the documentation:

 4) Install its own far routine as the new callback routine, using
    the QPI_SetIOCallback call. Your callback routine will be
    passed the following information:

     AX = Data for output
     CX = Type of I/O (see flag bits defined below)
     DX = Port number
     IF = 0 (interrupts are disabled)

 When the callback routine has finished its work, it should return
 far with all registers other than CX and DX preserved. If the
 routine is called to get input from a port, AX should be modified.
 The bit-mapped word in CX contains the following information:

 IOT_Output     equ   0000000000000100b
     ;      bit 2 is 1 if output,
     ;      0 if input

 IOT_Word      equ   0000000000001000b
     ;      bit 3 is 1 if word I/O,
     ;      0 if byte I/O

 IOT_IF       equ   0000001000000000b
     ;      bit 9 is the same as the
     ;      caller's interrupt flag
bjt42 commented 2 years ago

Hi, thanks for the info. I haven't looked at this in a very long time. Is the existing pushf/cli/popf just redundant then? Is there a bug in the code as is? Cheers

karcherm commented 2 years ago

It's just redundant. Your code works fine as it is now.

I was looking at port trapping in DOS in general, and SoftMPU came up quite high in Google as an open-source project on how to it with QEMM as well as EMM386. To be frank: the patch is more to "clean up code that might be use as reference code for QPI port trapping" than to improve stability, functionality or user experience of SoftMPU. Thus feel free to reject the pull request if you rather keep the known working state.