From f4e263796c3f9ba639adffce4e58ee14af67a27e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Tue, 14 Oct 2014 00:14:56 +0000 Subject: [PATCH] [NTVDM] - Call CpuUnsimulate in EmulatorTerminate so that we really stop the CPU, before stopping the rest of the VM. - We can reset CpuRunning to TRUE in CpuSimulate *only* if the VM is still running AND the CpuCallLevel is strictly positive (>=1 means, CPU halted or running; ==0 means, CPU stopped). svn path=/trunk/; revision=64741 --- reactos/subsystems/ntvdm/cpu/cpu.c | 16 +++------------- reactos/subsystems/ntvdm/cpu/cpu.h | 1 - reactos/subsystems/ntvdm/emulator.c | 1 + 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/reactos/subsystems/ntvdm/cpu/cpu.c b/reactos/subsystems/ntvdm/cpu/cpu.c index 662edfcb4e0..d9c3940b894 100644 --- a/reactos/subsystems/ntvdm/cpu/cpu.c +++ b/reactos/subsystems/ntvdm/cpu/cpu.c @@ -37,9 +37,7 @@ BOOLEAN CpuRunning = FALSE; /* No more than 'MaxCpuCallLevel' recursive CPU calls are allowed */ static const INT MaxCpuCallLevel = 32; -static INT CpuCallLevel = 0; - -// BOOLEAN VdmRunning = TRUE; +static INT CpuCallLevel = 0; // == 0: CPU stopped; >= 1: CPU running or halted #if 0 LPCWSTR ExceptionName[] = @@ -131,10 +129,10 @@ VOID CpuSimulate(VOID) DPRINT("CpuSimulate <-- Level %d\n", CpuCallLevel); CpuCallLevel--; - if (CpuCallLevel < 0) CpuCallLevel = 0; + if (!VdmRunning || CpuCallLevel < 0) CpuCallLevel = 0; /* This takes into account for reentrance */ - CpuRunning = TRUE; + if (VdmRunning && (CpuCallLevel > 0)) CpuRunning = TRUE; } VOID CpuUnsimulate(VOID) @@ -148,14 +146,6 @@ static VOID WINAPI CpuUnsimulateBop(LPWORD Stack) CpuUnsimulate(); } -#if 0 -VOID EmulatorTerminate(VOID) -{ - /* Stop the VDM */ - VdmRunning = FALSE; -} -#endif - /* PUBLIC FUNCTIONS ***********************************************************/ BOOLEAN CpuInitialize(VOID) diff --git a/reactos/subsystems/ntvdm/cpu/cpu.h b/reactos/subsystems/ntvdm/cpu/cpu.h index fd51b49da4c..d60d30d3d08 100644 --- a/reactos/subsystems/ntvdm/cpu/cpu.h +++ b/reactos/subsystems/ntvdm/cpu/cpu.h @@ -55,7 +55,6 @@ enum }; #endif extern FAST486_STATE EmulatorContext; -// extern BOOLEAN VdmRunning; /* FUNCTIONS ******************************************************************/ diff --git a/reactos/subsystems/ntvdm/emulator.c b/reactos/subsystems/ntvdm/emulator.c index 22eb25e847d..ac98ec6b931 100644 --- a/reactos/subsystems/ntvdm/emulator.c +++ b/reactos/subsystems/ntvdm/emulator.c @@ -177,6 +177,7 @@ VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack) VOID EmulatorTerminate(VOID) { /* Stop the VDM */ + CpuUnsimulate(); // Halt the CPU VdmRunning = FALSE; } -- 2.17.1