From dcd0795cd0cfee891f2268740b60f380cf416ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 18 Oct 2014 14:08:50 +0000 Subject: [PATCH] [FAST486]: Implement a basic support for the Trap Flag. svn path=/trunk/; revision=64803 --- reactos/lib/fast486/debug.c | 19 ++++++++++++++++--- reactos/lib/fast486/fast486.c | 24 +++++++++++++++++++----- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/reactos/lib/fast486/debug.c b/reactos/lib/fast486/debug.c index 0e1082083e0..9af5b9620a2 100644 --- a/reactos/lib/fast486/debug.c +++ b/reactos/lib/fast486/debug.c @@ -83,7 +83,21 @@ NextInst: * Check if there is an interrupt to execute, or a hardware interrupt signal * while interrupts are enabled. */ - if (State->IntStatus == FAST486_INT_EXECUTE) + if (State->Flags.Tf) + { + /* Perform the interrupt */ + Fast486PerformInterrupt(State, 0x01); + + /* + * Flags and TF are pushed on stack so we can reset TF now, + * to not break into the INT 0x01 handler. + * After the INT 0x01 handler returns, the flags and therefore + * TF are popped back off the stack and restored, so TF will be + * automatically reset to its previous state. + */ + State->Flags.Tf = FALSE; + } + else if (State->IntStatus == FAST486_INT_EXECUTE) { /* Perform the interrupt */ Fast486PerformInterrupt(State, State->PendingIntNum); @@ -91,8 +105,7 @@ NextInst: /* Clear the interrupt status */ State->IntStatus = FAST486_INT_NONE; } - else if (State->Flags.If && (State->IntStatus == FAST486_INT_SIGNAL) - && (State->IntAckCallback != NULL)) + else if (State->Flags.If && (State->IntStatus == FAST486_INT_SIGNAL)) { /* Acknowledge the interrupt to get the number */ State->PendingIntNum = State->IntAckCallback(State); diff --git a/reactos/lib/fast486/fast486.c b/reactos/lib/fast486/fast486.c index 7e3da4e90b4..21b238498e1 100644 --- a/reactos/lib/fast486/fast486.c +++ b/reactos/lib/fast486/fast486.c @@ -82,7 +82,21 @@ NextInst: * Check if there is an interrupt to execute, or a hardware interrupt signal * while interrupts are enabled. */ - if (State->IntStatus == FAST486_INT_EXECUTE) + if (State->Flags.Tf) + { + /* Perform the interrupt */ + Fast486PerformInterrupt(State, 0x01); + + /* + * Flags and TF are pushed on stack so we can reset TF now, + * to not break into the INT 0x01 handler. + * After the INT 0x01 handler returns, the flags and therefore + * TF are popped back off the stack and restored, so TF will be + * automatically reset to its previous state. + */ + State->Flags.Tf = FALSE; + } + else if (State->IntStatus == FAST486_INT_EXECUTE) { /* Perform the interrupt */ Fast486PerformInterrupt(State, State->PendingIntNum); @@ -90,8 +104,7 @@ NextInst: /* Clear the interrupt status */ State->IntStatus = FAST486_INT_NONE; } - else if (State->Flags.If && (State->IntStatus == FAST486_INT_SIGNAL) - && (State->IntAckCallback != NULL)) + else if (State->Flags.If && (State->IntStatus == FAST486_INT_SIGNAL)) { /* Acknowledge the interrupt to get the number */ State->PendingIntNum = State->IntAckCallback(State); @@ -171,8 +184,8 @@ Fast486IntAckCallback(PFAST486_STATE State) { UNREFERENCED_PARAMETER(State); - /* Return something... */ - return 0; + /* Return something... defaulted to single-step interrupt */ + return 0x01; } /* PUBLIC FUNCTIONS ***********************************************************/ @@ -211,6 +224,7 @@ Fast486Reset(PFAST486_STATE State) { FAST486_SEG_REGS i; + /* Save the callbacks and TLB */ FAST486_MEM_READ_PROC MemReadCallback = State->MemReadCallback; FAST486_MEM_WRITE_PROC MemWriteCallback = State->MemWriteCallback; FAST486_IO_READ_PROC IoReadCallback = State->IoReadCallback;