Skip to content

Commit 4793e44

Browse files
committed
disable MAIN_ISR_CHAINED for it is not complete yet.
1 parent 840c47a commit 4793e44

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

main.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ PROGNAME = "SBEMU";
3131
#define MAIN_TRAP_PIC_ONDEMAND 1
3232
#define MAIN_INSTALL_RM_ISR 1 //not needed. but to workaround some rm games' problem. need RAW_HOOk in dpmi_dj2.c
3333
#define MAIN_DOUBLE_OPL_VOLUME 1 //hack: double the amplitude of OPL PCM. should be 1 or 0
34-
#define MAIN_ISR_CHAINED 1 //auto calls next handler AFTER current handler exits
34+
#define MAIN_ISR_CHAINED 0 //auto calls next handler AFTER current handler exits
3535

3636
#define MAIN_TSR_INT 0x2D //AMIS multiplex. TODO: 0x2F?
3737
#define MAIN_TSR_INTSTART_ID 0x01 //start id
@@ -1012,18 +1012,21 @@ static void MAIN_InterruptPM()
10121012
//then because we're still in MAIN_InterruptPM, so MAIN_InterruptPM is never enterred agian (guarded by go32 or MAIN_ININT_PM),
10131013
//so the newly coming irq will never be processed and the IRQ will flood the system
10141014
//an alternative chained methods will EXIT MAIN_InterruptPM FIRST and calls next handler, which will avoid this case, see @MAIN_ISR_CHAINED
1015+
//but we need a hack if the default handler in IVT doesn't send EOI or masks the irq (TODO)
10151016

10161017
//MAIN_IntContext.EFLAGS |= (MAIN_InINT&MAIN_ININT_RM) ? (MAIN_IntContext.EFLAGS&CPU_VMFLAG) : 0;
10171018
HDPMIPT_GetInterrupContext(&MAIN_IntContext);
10181019
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
10191020
{
10201021
MAIN_Interrupt();
1022+
#if !MAIN_ISR_CHAINED
10211023
PIC_SendEOIWithIRQ(aui.card_irq);
1024+
#endif
10221025
}
10231026
#if !MAIN_ISR_CHAINED
10241027
else
10251028
{
1026-
if((MAIN_InINT&MAIN_ININT_RM) || (MAIN_IntContext.EFLAGS&CPU_VMFLAG))
1029+
if(/*(MAIN_InINT&MAIN_ININT_RM) || */(MAIN_IntContext.EFLAGS&CPU_VMFLAG))
10271030
DPMI_CallOldISR(&MAIN_IntHandlePM);
10281031
else
10291032
DPMI_CallOldISRWithContext(&MAIN_IntHandlePM, &MAIN_IntContext.regs);
@@ -1049,7 +1052,9 @@ static void MAIN_InterruptRM()
10491052
MAIN_IntContext.regs = MAIN_RMIntREG;
10501053
MAIN_IntContext.EFLAGS = MAIN_RMIntREG.w.flags | CPU_VMFLAG;
10511054
MAIN_Interrupt();
1055+
#if !MAIN_ISR_CHAINED
10521056
PIC_SendEOIWithIRQ(aui.card_irq);
1057+
#endif
10531058
}
10541059
#if !MAIN_ISR_CHAINED
10551060
else

sbemu/dpmi/dpmi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ void DPMI_HighFree(uint32_t segment);
306306
//convert real mode far pointer to linear addr
307307
#define DPMI_FP2L(f32) ((((f32)>>12)&0xFFFF0)+((f32)&0xFFFF))
308308
//convert far pointer (seg:off) to linear
309-
#define DPMI_SEGOFF2L(seg, off) ((((uint32_t)((seg)&0xFFFF))<<4) + ((off)&0xFFFF))
309+
#define DPMI_SEGOFF2L(seg, off) ((((uint32_t)(((uint32_t)seg)&0xFFFF))<<4) + ((off)&0xFFFF))
310310
//convert far pointer (seg:off) to 32bit far ptr
311311
#define DPMI_MKFP(seg, off) ((((uint32_t)((seg)&0xFFFF))<<16) | ((off)&0xFFFF))
312312

sbemu/pic.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323

2424
void PIC_SendEOIWithIRQ(uint8_t irq)
2525
{
26+
if(PIC_GetIRQ() != irq) //not gonna happen but just incase that SMM handles a shared interrupt and we don't need send it again
27+
return; //or it's possbile that SMM only process the interrupt without sending EOI, leaving it to IVT
28+
//just make it safe
29+
2630
if(irq == 7 || irq == 15) //check spurious irq
2731
return PIC_SendEOI();
2832
CLIS();

0 commit comments

Comments
 (0)