Use a helper function for stopping the VDM (in case we add other steps for that), instead of just setting the flag to TRUE.

svn path=/branches/ntvdm/; revision=62378
This commit is contained in:
Hermès Bélusca-Maïto 2014-03-02 14:37:51 +00:00
parent 8656d3a5f6
commit e53f7b173c
7 changed files with 37 additions and 28 deletions

View file

@ -75,7 +75,7 @@ Quit:
if (!Success)
{
/* We failed everything, stop the VDM */
VdmRunning = FALSE;
EmulatorTerminate();
}
break;

View file

@ -170,7 +170,7 @@ VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack)
Opcode[9]);
/* Stop the VDM */
VdmRunning = FALSE;
EmulatorTerminate();
return;
}
@ -198,7 +198,7 @@ VOID EmulatorSimulate(VOID)
CpuCallLevel, MaxCpuCallLevel);
/* Stop the VDM */
VdmRunning = FALSE;
EmulatorTerminate();
return;
}
CpuCallLevel++;
@ -219,6 +219,12 @@ VOID EmulatorUnsimulate(VOID)
CpuSimulate = FALSE;
}
VOID EmulatorTerminate(VOID)
{
/* Stop the VDM */
VdmRunning = FALSE;
}
VOID EmulatorInterrupt(BYTE Number)
{
/* Call the Fast486 API */
@ -236,13 +242,13 @@ VOID EmulatorSetA20(BOOLEAN Enabled)
A20Line = Enabled;
}
VOID WINAPI EmulatorDebugBreakBop(LPWORD Stack)
static VOID WINAPI EmulatorDebugBreakBop(LPWORD Stack)
{
DPRINT1("NTVDM: BOP_DEBUGGER\n");
DebugBreak();
}
VOID WINAPI EmulatorUnsimulateBop(LPWORD Stack)
static VOID WINAPI EmulatorUnsimulateBop(LPWORD Stack)
{
EmulatorUnsimulate();
}
@ -443,7 +449,7 @@ WINAPI
VDDTerminateVDM(VOID)
{
/* Stop the VDM */
VdmRunning = FALSE;
EmulatorTerminate();
}
PBYTE

View file

@ -119,16 +119,19 @@ UCHAR WINAPI EmulatorIntAcknowledge
VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack);
BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput);
VOID EmulatorExecute(WORD Segment, WORD Offset);
VOID EmulatorInterrupt(BYTE Number);
VOID EmulatorInterruptSignal(VOID);
VOID EmulatorStep(VOID);
VOID EmulatorSimulate(VOID);
VOID EmulatorUnsimulate(VOID);
VOID EmulatorCleanup(VOID);
VOID EmulatorTerminate(VOID);
VOID EmulatorInterrupt(BYTE Number);
VOID EmulatorInterruptSignal(VOID);
VOID EmulatorSetA20(BOOLEAN Enabled);
BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput);
VOID EmulatorCleanup(VOID);
#endif // _EMULATOR_H_
/* EOF */

View file

@ -214,8 +214,8 @@ static VOID WINAPI PS2WritePort(ULONG Port, BYTE Data)
case 0xFC:
case 0xFE:
{
/* Stop the simulation */
VdmRunning = FALSE;
/* Stop the VDM */
EmulatorTerminate();
break;
}
}
@ -243,8 +243,8 @@ static VOID WINAPI PS2WritePort(ULONG Port, BYTE Data)
/* Check if bit 0 is unset */
if (!(Data & (1 << 0)))
{
/* CPU disabled - end simulation */
VdmRunning = FALSE;
/* CPU disabled - Stop the VDM */
EmulatorTerminate();
}
/* Update the A20 line setting */

View file

@ -450,7 +450,7 @@ static BOOL VgaAttachToConsole(PCOORD Resolution)
if (!Success)
{
DisplayMessage(L"RegisterConsoleVDM failed with error %d\n", GetLastError());
VdmRunning = FALSE;
EmulatorTerminate();
return FALSE;
}
@ -982,7 +982,7 @@ static BOOL VgaEnterTextMode(PCOORD Resolution)
if (!VgaAttachToConsole(Resolution))
{
DisplayMessage(L"An unexpected error occurred!\n");
VdmRunning = FALSE;
EmulatorTerminate();
return FALSE;
}
@ -1045,7 +1045,7 @@ static VOID VgaChangeMode(VOID)
if (!VgaEnterTextMode(&Resolution))
{
DisplayMessage(L"An unexpected VGA error occurred while switching into text mode.");
VdmRunning = FALSE;
EmulatorTerminate();
return;
}
}
@ -1055,7 +1055,7 @@ static VOID VgaChangeMode(VOID)
if (!VgaEnterGraphicsMode(&Resolution))
{
DisplayMessage(L"An unexpected VGA error occurred while switching into graphics mode.");
VdmRunning = FALSE;
EmulatorTerminate();
return;
}
}

View file

@ -124,12 +124,11 @@ CreateVdmMenu(HANDLE ConOutHandle)
hConsoleMenu = ConsoleMenuControl(ConsoleOutput,
ID_SHOWHIDE_MOUSE,
ID_VDM_QUIT);
if (hConsoleMenu != NULL)
{
VdmMenuPos = GetMenuItemCount(hConsoleMenu);
AppendMenuItems(hConsoleMenu, VdmMainMenuItems);
DrawMenuBar(GetConsoleWindow());
}
if (hConsoleMenu == NULL) return;
VdmMenuPos = GetMenuItemCount(hConsoleMenu);
AppendMenuItems(hConsoleMenu, VdmMainMenuItems);
DrawMenuBar(GetConsoleWindow());
}
static VOID
@ -200,7 +199,7 @@ BOOL WINAPI ConsoleCtrlHandler(DWORD ControlType)
default:
{
/* Stop the VDM if the user logs out or closes the console */
VdmRunning = FALSE;
EmulatorTerminate();
}
}
return TRUE;
@ -256,7 +255,8 @@ DWORD WINAPI PumpConsoleInput(LPVOID Parameter)
break;
case ID_VDM_QUIT:
VdmRunning = FALSE;
/* Stop the VDM */
EmulatorTerminate();
break;
default:

View file

@ -188,7 +188,7 @@ Quit:
{
DPRINT1("Invalid VDD DLL Handle: %d\n", Entry);
/* Stop the VDM */
VdmRunning = FALSE;
EmulatorTerminate();
return;
}
@ -214,7 +214,7 @@ Quit:
{
DPRINT1("Invalid VDD DLL Handle: %d\n", Entry);
/* Stop the VDM */
VdmRunning = FALSE;
EmulatorTerminate();
return;
}