Skip to content

Commit 3e4cd68

Browse files
committed
MAIN: fix interrupt not chained properly due to f5c6321
1 parent 84135ae commit 3e4cd68

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

main.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ static uint32_t MAIN_DMA_MappedAddr = 0;
5252
static uint8_t MAIN_QEMM_Present = 0;
5353
static uint8_t MAIN_HDPMI_Present = 0;
5454
static uint8_t MAIN_InINT;
55+
#define MAIN_ININT_PM 0x01
56+
#define MAIN_ININT_RM 0x02
5557

5658
SBEMU_EXTFUNS MAIN_SbemuExtFun;
5759

@@ -917,30 +919,34 @@ int main(int argc, char* argv[])
917919

918920
static void MAIN_InterruptPM()
919921
{
920-
if(MAIN_InINT) return;
922+
if(MAIN_InINT&MAIN_ININT_PM) return;
923+
//DBG_Log("INTPM %d\n", MAIN_InINT);
924+
921925
HDPMIPT_GetInterrupContext(&MAIN_IntContext);
922-
if(aui.card_handler->irq_routine && aui.card_handler->irq_routine(&aui)) //check if the irq belong the sound card
926+
if(!MAIN_InINT && aui.card_handler->irq_routine && aui.card_handler->irq_routine(&aui)) //check if the irq belong the sound card
923927
{
924928
MAIN_Interrupt();
925929
PIC_SendEOIWithIRQ(aui.card_irq);
926930
}
927931
else
928932
{
929-
BOOL InInt = MAIN_InINT;
930-
MAIN_InINT = TRUE;
931-
if(MAIN_IntContext.EFLAGS&CPU_VMFLAG)
933+
MAIN_InINT |= MAIN_ININT_PM;
934+
if((MAIN_InINT&MAIN_ININT_RM) || (MAIN_IntContext.EFLAGS&CPU_VMFLAG))
932935
DPMI_CallOldISR(&MAIN_IntHandlePM);
933936
else
934937
DPMI_CallOldISRWithContext(&MAIN_IntHandlePM, &MAIN_IntContext.regs);
935938
PIC_UnmaskIRQ(aui.card_irq);
936-
MAIN_InINT = InInt;
939+
MAIN_InINT &= ~MAIN_ININT_PM;
940+
//DBG_Log("INTPME %d\n", MAIN_InINT);
937941
}
938942
}
939943

940944
static void MAIN_InterruptRM()
941945
{
942-
if(MAIN_InINT) return;
943-
if(aui.card_handler->irq_routine && aui.card_handler->irq_routine(&aui)) //check if the irq belong the sound card
946+
if(MAIN_InINT&MAIN_ININT_RM) return;
947+
//DBG_Log("INTRM %d\n", MAIN_InINT);
948+
949+
if(!MAIN_InINT && aui.card_handler->irq_routine && aui.card_handler->irq_routine(&aui)) //check if the irq belong the sound card
944950
{
945951
MAIN_IntContext.regs = MAIN_RMIntREG;
946952
MAIN_IntContext.EFLAGS = MAIN_RMIntREG.w.flags | CPU_VMFLAG;
@@ -949,12 +955,12 @@ static void MAIN_InterruptRM()
949955
}
950956
else
951957
{
952-
BOOL InInt = MAIN_InINT;
953-
MAIN_InINT = TRUE;
958+
MAIN_InINT |= MAIN_ININT_RM;
954959
DPMI_REG r = MAIN_RMIntREG; //don't modify MAIN_RMIntREG on hardware interrupt
955960
DPMI_CallRealModeOldISR(&MAIN_IntHandleRM, &r);
956961
PIC_UnmaskIRQ(aui.card_irq);
957-
MAIN_InINT = InInt;
962+
MAIN_InINT &= ~MAIN_ININT_RM;
963+
//DBG_Log("INTRME %d\n", MAIN_InINT);
958964
}
959965
}
960966

sbemu/dpmi/dbgutil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#ifndef DEBUG
1212
#define DEBUG 0
13-
#elif DEBUG != 0
13+
#else
1414
#undef DEBUG
1515
#define DEBUG 1
1616
#endif

sbemu/dpmi/dpmi_dj2.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,19 @@ uint32_t DPMI_CallOldISRWithContext(DPMI_ISR_HANDLE* inputp handle, const DPMI_R
558558
"mov %0, %%eax \n\t mov %1, %%ecx \n\t mov %2, %%edx \n\t mov %3, %%ebx \n\t mov %4, %%esi \n\t mov %5, %%edi \n\t"
559559
"push %6 \n\t pop %%ds \n\t push %7 \n\t pop %%es \n\t push %8 \n\t pop %%fs \n\t push %9 \n\t pop %%gs \n\t"
560560

561-
//"pushl %10 \n\t andw $0xFCFF, (%%esp) \n\t" //don't restore ebp, lcall uses it.
561+
"push %12 \n\t"
562+
"push %11 \n\t"
563+
//"pushl %10 \n\t andw $0xFCFF, (%%esp) \n\t"
562564
"pushfl \n\t"
563-
"lcall *%11 \n\t"
565+
"mov %13, %%ebp \n\t"
566+
"lcall *4(%%esp) \n\t"
567+
"add $8, %%esp \n\t"
564568

565569
"pop %%gs \n\t pop %%fs \n\t pop %%es \n\t pop %%ds \n\t"
566570
"popfl \n\t popal \n\t"
567571
::"m"(r.d.eax),"m"(r.d.ecx),"m"(r.d.edx),"m"(r.d.ebx),"m"(r.d.esi),"m"(r.d.edi),
568572
"m"(r.w.ds),"m"(r.w.es),"m"(r.w.fs),"m"(r.w.gs),
569-
"m"(r.w.flags), "m"(h.old_offset)
573+
"m"(r.w.flags), "m"(h.old_offset), "m"(h.old_cs), "m"(r.d.ebp)
570574
);
571575
return 0;
572576
}

0 commit comments

Comments
 (0)