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

Remove interrupt disabling from QPI port trapping path #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

karcherm
Copy link

@karcherm karcherm commented Apr 4, 2022

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

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
Copy link
Owner

bjt42 commented Apr 4, 2022

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
Copy link
Author

karcherm commented Apr 4, 2022

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.

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.

2 participants