diff --git a/main.c b/main.c index f0eee4e7..6c916aa0 100644 --- a/main.c +++ b/main.c @@ -52,6 +52,8 @@ static uint32_t MAIN_DMA_MappedAddr = 0; static uint8_t MAIN_QEMM_Present = 0; static uint8_t MAIN_HDPMI_Present = 0; static uint8_t MAIN_InINT; +#define MAIN_ININT_PM 0x01 +#define MAIN_ININT_RM 0x02 SBEMU_EXTFUNS MAIN_SbemuExtFun; @@ -917,30 +919,34 @@ int main(int argc, char* argv[]) static void MAIN_InterruptPM() { - if(MAIN_InINT) return; + if(MAIN_InINT&MAIN_ININT_PM) return; + //DBG_Log("INTPM %d\n", MAIN_InINT); + HDPMIPT_GetInterrupContext(&MAIN_IntContext); - if(aui.card_handler->irq_routine && aui.card_handler->irq_routine(&aui)) //check if the irq belong the sound card + if(!MAIN_InINT && 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 { - BOOL InInt = MAIN_InINT; - MAIN_InINT = TRUE; - if(MAIN_IntContext.EFLAGS&CPU_VMFLAG) + 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 = InInt; + MAIN_InINT &= ~MAIN_ININT_PM; + //DBG_Log("INTPME %d\n", MAIN_InINT); } } static void MAIN_InterruptRM() { - if(MAIN_InINT) return; - if(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) return; + //DBG_Log("INTRM %d\n", MAIN_InINT); + + if(!MAIN_InINT && 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; @@ -949,12 +955,12 @@ static void MAIN_InterruptRM() } else { - BOOL InInt = MAIN_InINT; - MAIN_InINT = TRUE; + 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 = InInt; + MAIN_InINT &= ~MAIN_ININT_RM; + //DBG_Log("INTRME %d\n", MAIN_InINT); } } diff --git a/sbemu/dpmi/dbgutil.h b/sbemu/dpmi/dbgutil.h index 9b8d0e7b..f2edf18b 100644 --- a/sbemu/dpmi/dbgutil.h +++ b/sbemu/dpmi/dbgutil.h @@ -10,7 +10,7 @@ #ifndef DEBUG #define DEBUG 0 -#elif DEBUG != 0 +#else #undef DEBUG #define DEBUG 1 #endif diff --git a/sbemu/dpmi/dpmi_dj2.c b/sbemu/dpmi/dpmi_dj2.c index d6ef56f6..2ae5d210 100644 --- a/sbemu/dpmi/dpmi_dj2.c +++ b/sbemu/dpmi/dpmi_dj2.c @@ -558,15 +558,19 @@ uint32_t DPMI_CallOldISRWithContext(DPMI_ISR_HANDLE* inputp handle, const DPMI_R "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" "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" - //"pushl %10 \n\t andw $0xFCFF, (%%esp) \n\t" //don't restore ebp, lcall uses it. + "push %12 \n\t" + "push %11 \n\t" + //"pushl %10 \n\t andw $0xFCFF, (%%esp) \n\t" "pushfl \n\t" - "lcall *%11 \n\t" + "mov %13, %%ebp \n\t" + "lcall *4(%%esp) \n\t" + "add $8, %%esp \n\t" "pop %%gs \n\t pop %%fs \n\t pop %%es \n\t pop %%ds \n\t" "popfl \n\t popal \n\t" ::"m"(r.d.eax),"m"(r.d.ecx),"m"(r.d.edx),"m"(r.d.ebx),"m"(r.d.esi),"m"(r.d.edi), "m"(r.w.ds),"m"(r.w.es),"m"(r.w.fs),"m"(r.w.gs), - "m"(r.w.flags), "m"(h.old_offset) + "m"(r.w.flags), "m"(h.old_offset), "m"(h.old_cs), "m"(r.d.ebp) ); return 0; }