Author: aandrejevic Date: Fri Oct 18 22:50:00 2013 New Revision: 60696
URL: http://svn.reactos.org/svn/reactos?rev=60696&view=rev Log: [SOFT386] Implement the hardware interrupt system. Modify Soft386Interrupt to assume hardware interrupts, because software interrupts from outside the emulator may cause race conditions.
Modified: branches/ntvdm/include/reactos/libs/soft386/soft386.h branches/ntvdm/lib/soft386/soft386.c branches/ntvdm/subsystems/ntvdm/emulator.c
Modified: branches/ntvdm/include/reactos/libs/soft386/soft386.h URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/include/reactos/libs/soft3... ============================================================================== --- branches/ntvdm/include/reactos/libs/soft386/soft386.h [iso-8859-1] (original) +++ branches/ntvdm/include/reactos/libs/soft386/soft386.h [iso-8859-1] Fri Oct 18 22:50:00 2013 @@ -342,6 +342,7 @@ ULONG PrefixFlags; SOFT386_SEG_REGS SegmentOverride; BOOLEAN HardwareInt; + UCHAR PendingIntNum; };
/* FUNCTIONS ******************************************************************/ @@ -372,7 +373,7 @@
VOID NTAPI -Soft386Interrupt(PSOFT386_STATE State, UCHAR Number, BOOLEAN Hardware); +Soft386Interrupt(PSOFT386_STATE State, UCHAR Number);
VOID NTAPI
Modified: branches/ntvdm/lib/soft386/soft386.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/soft386.c?rev=... ============================================================================== --- branches/ntvdm/lib/soft386/soft386.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/soft386.c [iso-8859-1] Fri Oct 18 22:50:00 2013 @@ -56,8 +56,30 @@ /* Main execution loop */ do { - /* If this is a new instruction, save the IP */ - if (State->PrefixFlags == 0) State->SavedInstPtr = State->InstPtr; + /* Check if this is a new instruction */ + if (State->PrefixFlags == 0) + { + State->SavedInstPtr = State->InstPtr; + + /* Check if interrupts are enabled and there is an interrupt pending */ + if (State->Flags.If && State->HardwareInt) + { + SOFT386_IDT_ENTRY IdtEntry; + + /* Get the interrupt vector */ + if (Soft386GetIntVector(State, State->PendingIntNum, &IdtEntry)) + { + /* Perform the interrupt */ + Soft386InterruptInternal(State, + IdtEntry.Selector, + MAKELONG(IdtEntry.Offset, IdtEntry.OffsetHigh), + IdtEntry.Type); + } + + /* Clear the interrupt pending flag */ + State->HardwareInt = FALSE; + } + }
/* Perform an instruction fetch */ if (!Soft386FetchByte(State, &Opcode)) continue; @@ -273,27 +295,11 @@
VOID NTAPI -Soft386Interrupt(PSOFT386_STATE State, UCHAR Number, BOOLEAN Hardware) -{ - SOFT386_IDT_ENTRY IdtEntry; - - if (Hardware) - { - /* Set the hardware interrupt flag */ - State->HardwareInt = TRUE; - } - - if (!Soft386GetIntVector(State, Number, &IdtEntry)) - { - /* An exception occurred, let the handler execute */ - return; - } - - /* Perform the interrupt */ - Soft386InterruptInternal(State, - IdtEntry.Selector, - MAKELONG(IdtEntry.Offset, IdtEntry.OffsetHigh), - IdtEntry.Type); +Soft386Interrupt(PSOFT386_STATE State, UCHAR Number) +{ + /* Set the hardware interrupt flag */ + State->HardwareInt = TRUE; + State->PendingIntNum = Number; }
VOID
Modified: branches/ntvdm/subsystems/ntvdm/emulator.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator.... ============================================================================== --- branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] Fri Oct 18 22:50:00 2013 @@ -473,7 +473,7 @@ softx86_make_simple_interrupt_call(&EmulatorContext, &Segment, &Offset); #else /* Call the Soft386 API */ - Soft386Interrupt(&EmulatorContext, Number, FALSE); + Soft386Interrupt(&EmulatorContext, Number); #endif }
@@ -484,7 +484,7 @@ softx86_ext_hw_signal(&EmulatorContext, Number); #else /* Call the Soft386 API */ - Soft386Interrupt(&EmulatorContext, Number, TRUE); + Soft386Interrupt(&EmulatorContext, Number); #endif }