Skip to content

Commit

Permalink
main: continue fix interrupt handler recursion.
Browse files Browse the repository at this point in the history
  • Loading branch information
crazii committed Jan 24, 2024
1 parent 312a962 commit 2c1149d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,32 +921,33 @@ static void MAIN_InterruptPM()
{
if(MAIN_InINT&MAIN_ININT_PM) return;
//DBG_Log("INTPM %d\n", MAIN_InINT);
MAIN_InINT |= MAIN_ININT_PM;

HDPMIPT_GetInterrupContext(&MAIN_IntContext);
if(!MAIN_InINT && aui.card_handler->irq_routine && aui.card_handler->irq_routine(&aui)) //check if the irq belong the sound card
if(!(MAIN_InINT&MAIN_ININT_RM) && aui.card_handler->irq_routine && aui.card_handler->irq_routine(&aui)) //check if the irq belong the sound card
{
MAIN_Interrupt();
PIC_SendEOIWithIRQ(aui.card_irq);
}
else
{
MAIN_InINT |= MAIN_ININT_PM;
if((MAIN_InINT&MAIN_ININT_RM) || (MAIN_IntContext.EFLAGS&CPU_VMFLAG))
DPMI_CallOldISR(&MAIN_IntHandlePM);
else
DPMI_CallOldISRWithContext(&MAIN_IntHandlePM, &MAIN_IntContext.regs);
PIC_UnmaskIRQ(aui.card_irq);
MAIN_InINT &= ~MAIN_ININT_PM;
//DBG_Log("INTPME %d\n", MAIN_InINT);
}
MAIN_InINT &= ~MAIN_ININT_PM;
}

static void MAIN_InterruptRM()
{
if(MAIN_InINT&MAIN_ININT_RM) return;
//DBG_Log("INTRM %d\n", MAIN_InINT);
MAIN_InINT |= MAIN_ININT_RM;

if(!MAIN_InINT && aui.card_handler->irq_routine && aui.card_handler->irq_routine(&aui)) //check if the irq belong the sound card
if(!(MAIN_InINT&MAIN_ININT_PM) && aui.card_handler->irq_routine && aui.card_handler->irq_routine(&aui)) //check if the irq belong the sound card
{
MAIN_IntContext.regs = MAIN_RMIntREG;
MAIN_IntContext.EFLAGS = MAIN_RMIntREG.w.flags | CPU_VMFLAG;
Expand All @@ -955,13 +956,12 @@ static void MAIN_InterruptRM()
}
else
{
MAIN_InINT |= MAIN_ININT_RM;
DPMI_REG r = MAIN_RMIntREG; //don't modify MAIN_RMIntREG on hardware interrupt
DPMI_CallRealModeOldISR(&MAIN_IntHandleRM, &r);
PIC_UnmaskIRQ(aui.card_irq);
MAIN_InINT &= ~MAIN_ININT_RM;
//DBG_Log("INTRME %d\n", MAIN_InINT);
}
MAIN_InINT &= ~MAIN_ININT_RM;
}

static void MAIN_Interrupt()
Expand Down
2 changes: 1 addition & 1 deletion sbemu/untrapio.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _UNTRAPIO_H_
#define _UNTRAPIO_H_
//Untrapped IO wrapper function
//in PM mode, HDPMI will call the trap handler with IOPL0 so direct in/out works, but in RM, QEMM doesn't do that,
//in PM mode, HDPMI will call the trap handler with IOPL0 so direct in/out works - now with IOPL3, but in RM, QEMM doesn't do that,
//so QEMM's untrapped function need to be called, this works for both PM & RM mode

#include <stdint.h>
Expand Down

0 comments on commit 2c1149d

Please sign in to comment.