From cc89902e00088970b069e5001a1773322799a793 Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Sun, 10 Nov 2013 00:53:05 +0000 Subject: [PATCH] [NTVDM] Don't enable interrupts unless it's necessary in the interrupt handler. [FAST486] When handling interrupt signals, make sure at least one instruction is executed, to prevent the CPU from being completely blocked by interrupt signals. svn path=/branches/ntvdm/; revision=60910 --- lib/fast486/fast486.c | 21 +++++++++++---------- subsystems/ntvdm/int32.c | 6 ++++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/fast486/fast486.c b/lib/fast486/fast486.c index dcb98b30157..05ee5596432 100644 --- a/lib/fast486/fast486.c +++ b/lib/fast486/fast486.c @@ -63,19 +63,10 @@ Fast486ExecutionControl(PFAST486_STATE State, INT Command) * Check if there is an interrupt to execute, or a hardware interrupt signal * while interrupts are enabled. */ - if ((State->IntStatus == FAST486_INT_EXECUTE) - || (State->Flags.If - && (State->IntAckCallback != NULL) - && (State->IntStatus == FAST486_INT_SIGNAL))) + if (State->IntStatus == FAST486_INT_EXECUTE) { FAST486_IDT_ENTRY IdtEntry; - if (State->IntStatus == FAST486_INT_SIGNAL) - { - /* Acknowledge the interrupt to get the number */ - State->PendingIntNum = State->IntAckCallback(State); - } - /* Get the interrupt vector */ if (Fast486GetIntVector(State, State->PendingIntNum, &IdtEntry)) { @@ -89,6 +80,16 @@ Fast486ExecutionControl(PFAST486_STATE State, INT Command) /* Clear the interrupt status */ State->IntStatus = FAST486_INT_NONE; } + else if (State->Flags.If + && (State->IntAckCallback != NULL) + && (State->IntStatus == FAST486_INT_SIGNAL)) + { + /* Acknowledge the interrupt to get the number */ + State->PendingIntNum = State->IntAckCallback(State); + + /* Set the interrupt status to execute on the next instruction */ + State->IntStatus = FAST486_INT_EXECUTE; + } } /* Perform an instruction fetch */ diff --git a/subsystems/ntvdm/int32.c b/subsystems/ntvdm/int32.c index 8e039333587..8d4455511ec 100644 --- a/subsystems/ntvdm/int32.c +++ b/subsystems/ntvdm/int32.c @@ -139,7 +139,7 @@ VOID WINAPI InitializeInt32(WORD BiosSegment) { IntVecTable[i] = MAKELONG(Offset, BiosSegment); - BiosCode[Offset++] = 0xFB; // sti + BiosCode[Offset++] = 0xFA; // cli BiosCode[Offset++] = 0x6A; // push i BiosCode[Offset++] = (UCHAR)i; @@ -158,11 +158,13 @@ VOID WINAPI InitializeInt32(WORD BiosSegment) BiosCode[Offset++] = 0x73; // jnc EXIT (offset +3) BiosCode[Offset++] = 0x03; + BiosCode[Offset++] = 0xFB; // sti + // HACK: The following instruction should be HLT! BiosCode[Offset++] = 0x90; // nop BiosCode[Offset++] = 0xEB; // jmp BOP_SEQ (offset -10) - BiosCode[Offset++] = 0xF6; + BiosCode[Offset++] = 0xF5; // EXIT: BiosCode[Offset++] = 0x83; // add sp, 4