2013-06-17 00:00:36 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: GPL - See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Virtual DOS Machine
|
2015-09-18 17:01:49 +00:00
|
|
|
* FILE: subsystems/mvdm/ntvdm/emulator.c
|
2013-06-17 00:00:36 +00:00
|
|
|
* PURPOSE: Minimal x86 machine emulator for the VDM
|
|
|
|
* PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
|
|
|
|
*/
|
|
|
|
|
2015-10-04 11:49:28 +00:00
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
|
2015-10-03 19:17:55 +00:00
|
|
|
#include "ntvdm.h"
|
|
|
|
|
2013-07-22 13:51:26 +00:00
|
|
|
#define NDEBUG
|
2015-10-03 19:17:55 +00:00
|
|
|
#include <debug.h>
|
2013-07-22 13:51:26 +00:00
|
|
|
|
2015-10-04 11:49:28 +00:00
|
|
|
#include "emulator.h"
|
|
|
|
#include "memory.h"
|
|
|
|
|
|
|
|
#include "cpu/callback.h"
|
|
|
|
#include "cpu/cpu.h"
|
|
|
|
#include "cpu/bop.h"
|
|
|
|
#include <isvbop.h>
|
|
|
|
|
|
|
|
#include "int32.h"
|
|
|
|
|
|
|
|
#include "clock.h"
|
|
|
|
#include "bios/rom.h"
|
|
|
|
#include "hardware/cmos.h"
|
|
|
|
#include "hardware/disk.h"
|
|
|
|
#include "hardware/dma.h"
|
|
|
|
#include "hardware/keyboard.h"
|
|
|
|
#include "hardware/mouse.h"
|
|
|
|
#include "hardware/pic.h"
|
|
|
|
#include "hardware/pit.h"
|
|
|
|
#include "hardware/ppi.h"
|
|
|
|
#include "hardware/ps2.h"
|
|
|
|
#include "hardware/sound/speaker.h"
|
|
|
|
#include "hardware/video/svga.h"
|
2015-11-07 20:07:12 +00:00
|
|
|
/**/
|
|
|
|
#include "./console/video.h"
|
|
|
|
/**/
|
2015-10-04 11:49:28 +00:00
|
|
|
|
|
|
|
#include "vddsup.h"
|
|
|
|
#include "io.h"
|
|
|
|
|
2013-06-26 22:58:41 +00:00
|
|
|
/* PRIVATE VARIABLES **********************************************************/
|
|
|
|
|
2014-01-11 20:59:27 +00:00
|
|
|
LPVOID BaseAddress = NULL;
|
|
|
|
BOOLEAN VdmRunning = TRUE;
|
2013-07-07 20:53:23 +00:00
|
|
|
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
HANDLE VdmTaskEvent = NULL;
|
2014-02-01 16:32:20 +00:00
|
|
|
static HANDLE InputThread = NULL;
|
|
|
|
|
2014-01-25 00:21:51 +00:00
|
|
|
LPCWSTR ExceptionName[] =
|
|
|
|
{
|
|
|
|
L"Division By Zero",
|
|
|
|
L"Debug",
|
|
|
|
L"Unexpected Error",
|
|
|
|
L"Breakpoint",
|
|
|
|
L"Integer Overflow",
|
|
|
|
L"Bound Range Exceeded",
|
|
|
|
L"Invalid Opcode",
|
|
|
|
L"FPU Not Available"
|
|
|
|
};
|
|
|
|
|
2013-12-16 23:57:35 +00:00
|
|
|
/* BOP Identifiers */
|
|
|
|
#define BOP_DEBUGGER 0x56 // Break into the debugger from a 16-bit app
|
|
|
|
|
2013-06-26 22:58:41 +00:00
|
|
|
/* PRIVATE FUNCTIONS **********************************************************/
|
|
|
|
|
2015-06-12 03:30:40 +00:00
|
|
|
UCHAR FASTCALL EmulatorIntAcknowledge(PFAST486_STATE State)
|
2013-10-27 00:37:01 +00:00
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(State);
|
|
|
|
|
|
|
|
/* Get the interrupt number from the PIC */
|
|
|
|
return PicGetInterrupt();
|
|
|
|
}
|
|
|
|
|
2015-06-12 03:30:40 +00:00
|
|
|
VOID FASTCALL EmulatorFpu(PFAST486_STATE State)
|
2015-01-03 15:16:41 +00:00
|
|
|
{
|
|
|
|
/* The FPU is wired to IRQ 13 */
|
|
|
|
PicInterruptRequest(13);
|
|
|
|
}
|
|
|
|
|
2014-02-01 16:32:20 +00:00
|
|
|
VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack)
|
|
|
|
{
|
|
|
|
WORD CodeSegment, InstructionPointer;
|
|
|
|
PBYTE Opcode;
|
|
|
|
|
|
|
|
ASSERT(ExceptionNumber < 8);
|
|
|
|
|
|
|
|
/* Get the CS:IP */
|
|
|
|
InstructionPointer = Stack[STACK_IP];
|
|
|
|
CodeSegment = Stack[STACK_CS];
|
|
|
|
Opcode = (PBYTE)SEG_OFF_TO_PTR(CodeSegment, InstructionPointer);
|
|
|
|
|
|
|
|
/* Display a message to the user */
|
2015-05-03 02:11:32 +00:00
|
|
|
DisplayMessage(L"Exception: %s occurred at %04X:%04X\n"
|
2014-02-01 16:32:20 +00:00
|
|
|
L"Opcode: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",
|
|
|
|
ExceptionName[ExceptionNumber],
|
|
|
|
CodeSegment,
|
|
|
|
InstructionPointer,
|
|
|
|
Opcode[0],
|
|
|
|
Opcode[1],
|
|
|
|
Opcode[2],
|
|
|
|
Opcode[3],
|
|
|
|
Opcode[4],
|
|
|
|
Opcode[5],
|
|
|
|
Opcode[6],
|
|
|
|
Opcode[7],
|
|
|
|
Opcode[8],
|
|
|
|
Opcode[9]);
|
|
|
|
|
2014-10-13 18:51:40 +00:00
|
|
|
Fast486DumpState(&EmulatorContext);
|
|
|
|
|
2014-02-01 16:32:20 +00:00
|
|
|
/* Stop the VDM */
|
2014-03-02 14:37:51 +00:00
|
|
|
EmulatorTerminate();
|
2014-02-01 16:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID EmulatorInterruptSignal(VOID)
|
|
|
|
{
|
|
|
|
/* Call the Fast486 API */
|
|
|
|
Fast486InterruptSignal(&EmulatorContext);
|
|
|
|
}
|
|
|
|
|
2014-03-02 14:37:51 +00:00
|
|
|
static VOID WINAPI EmulatorDebugBreakBop(LPWORD Stack)
|
2013-12-16 23:57:35 +00:00
|
|
|
{
|
|
|
|
DPRINT1("NTVDM: BOP_DEBUGGER\n");
|
|
|
|
DebugBreak();
|
|
|
|
}
|
|
|
|
|
2014-01-28 20:24:24 +00:00
|
|
|
static VOID WINAPI PitChan0Out(LPVOID Param, BOOLEAN State)
|
|
|
|
{
|
|
|
|
if (State)
|
|
|
|
{
|
|
|
|
DPRINT("PicInterruptRequest\n");
|
|
|
|
PicInterruptRequest(0); // Raise IRQ 0
|
|
|
|
}
|
|
|
|
// else < Lower IRQ 0 >
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID WINAPI PitChan1Out(LPVOID Param, BOOLEAN State)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
if (State)
|
|
|
|
{
|
|
|
|
/* Set bit 4 of Port 61h */
|
|
|
|
Port61hState |= 1 << 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Clear bit 4 of Port 61h */
|
|
|
|
Port61hState &= ~(1 << 4);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
Port61hState = (Port61hState & 0xEF) | (State << 4);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID WINAPI PitChan2Out(LPVOID Param, BOOLEAN State)
|
|
|
|
{
|
2014-09-27 15:33:27 +00:00
|
|
|
BYTE OldPort61hState = Port61hState;
|
2014-01-29 00:25:43 +00:00
|
|
|
|
2014-01-28 20:24:24 +00:00
|
|
|
#if 0
|
|
|
|
if (State)
|
|
|
|
{
|
|
|
|
/* Set bit 5 of Port 61h */
|
|
|
|
Port61hState |= 1 << 5;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Clear bit 5 of Port 61h */
|
|
|
|
Port61hState &= ~(1 << 5);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
Port61hState = (Port61hState & 0xDF) | (State << 5);
|
|
|
|
#endif
|
2014-09-27 15:33:27 +00:00
|
|
|
|
|
|
|
if ((OldPort61hState ^ Port61hState) & 0x20)
|
|
|
|
{
|
|
|
|
DPRINT("PitChan2Out -- Port61hState changed\n");
|
2014-11-08 21:45:20 +00:00
|
|
|
SpeakerChange(Port61hState);
|
2014-09-27 15:33:27 +00:00
|
|
|
}
|
2014-01-28 20:24:24 +00:00
|
|
|
}
|
|
|
|
|
2014-09-16 00:51:15 +00:00
|
|
|
|
|
|
|
static DWORD
|
|
|
|
WINAPI
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
ConsoleEventThread(LPVOID Parameter)
|
2014-09-16 00:51:15 +00:00
|
|
|
{
|
|
|
|
HANDLE ConsoleInput = (HANDLE)Parameter;
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
HANDLE WaitHandles[2];
|
|
|
|
DWORD WaitResult;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For optimization purposes, Windows (and hence ReactOS, too, for
|
|
|
|
* compatibility reasons) uses a static buffer if no more than five
|
|
|
|
* input records are read. Otherwise a new buffer is used.
|
|
|
|
* The client-side expects that we know this behaviour.
|
|
|
|
* See consrv/coninput.c
|
|
|
|
*
|
|
|
|
* We exploit here this optimization by also using a buffer of 5 records.
|
|
|
|
*/
|
|
|
|
INPUT_RECORD InputRecords[5];
|
|
|
|
ULONG NumRecords, i;
|
|
|
|
|
|
|
|
WaitHandles[0] = VdmTaskEvent;
|
|
|
|
WaitHandles[1] = GetConsoleInputWaitHandle();
|
2014-09-16 00:51:15 +00:00
|
|
|
|
|
|
|
while (VdmRunning)
|
|
|
|
{
|
|
|
|
/* Make sure the task event is signaled */
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
WaitResult = WaitForMultipleObjects(ARRAYSIZE(WaitHandles),
|
|
|
|
WaitHandles,
|
|
|
|
TRUE,
|
|
|
|
INFINITE);
|
|
|
|
switch (WaitResult)
|
|
|
|
{
|
|
|
|
case WAIT_OBJECT_0 + 0:
|
|
|
|
case WAIT_OBJECT_0 + 1:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return GetLastError();
|
|
|
|
}
|
2014-09-16 00:51:15 +00:00
|
|
|
|
|
|
|
/* Wait for an input record */
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
if (!ReadConsoleInputExW(ConsoleInput,
|
|
|
|
InputRecords,
|
|
|
|
ARRAYSIZE(InputRecords),
|
|
|
|
&NumRecords,
|
|
|
|
CONSOLE_READ_CONTINUE))
|
2014-09-16 00:51:15 +00:00
|
|
|
{
|
|
|
|
DWORD LastError = GetLastError();
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
DPRINT1("Error reading console input (0x%p, %lu) - Error %lu\n", ConsoleInput, NumRecords, LastError);
|
2014-09-16 00:51:15 +00:00
|
|
|
return LastError;
|
|
|
|
}
|
|
|
|
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
// ASSERT(NumRecords != 0);
|
|
|
|
if (NumRecords == 0)
|
2014-09-16 00:51:15 +00:00
|
|
|
{
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
DPRINT1("Got NumRecords == 0!\n");
|
|
|
|
continue;
|
|
|
|
}
|
2014-09-16 00:51:15 +00:00
|
|
|
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
/* Dispatch the events */
|
|
|
|
for (i = 0; i < NumRecords; i++)
|
|
|
|
{
|
|
|
|
/* Check the event type */
|
|
|
|
switch (InputRecords[i].EventType)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Hardware events
|
|
|
|
*/
|
|
|
|
case KEY_EVENT:
|
|
|
|
KeyboardEventHandler(&InputRecords[i].Event.KeyEvent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MOUSE_EVENT:
|
|
|
|
MouseEventHandler(&InputRecords[i].Event.MouseEvent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINDOW_BUFFER_SIZE_EVENT:
|
|
|
|
ScreenEventHandler(&InputRecords[i].Event.WindowBufferSizeEvent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interface events
|
|
|
|
*/
|
|
|
|
case MENU_EVENT:
|
|
|
|
MenuEventHandler(&InputRecords[i].Event.MenuEvent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FOCUS_EVENT:
|
|
|
|
FocusEventHandler(&InputRecords[i].Event.FocusEvent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DPRINT1("Unknown input event type 0x%04x\n", InputRecords[i].EventType);
|
|
|
|
break;
|
|
|
|
}
|
2014-09-16 00:51:15 +00:00
|
|
|
}
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
|
|
|
|
/* Let the console subsystem queue some new events */
|
|
|
|
Sleep(10);
|
2014-09-16 00:51:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
static VOID PauseEventThread(VOID)
|
|
|
|
{
|
|
|
|
ResetEvent(VdmTaskEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID ResumeEventThread(VOID)
|
|
|
|
{
|
|
|
|
SetEvent(VdmTaskEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-17 00:00:36 +00:00
|
|
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
|
|
|
|
2014-09-28 16:27:30 +00:00
|
|
|
static VOID
|
|
|
|
DumpMemoryRaw(HANDLE hFile)
|
2014-05-17 23:49:35 +00:00
|
|
|
{
|
2014-09-28 16:27:30 +00:00
|
|
|
PVOID Buffer;
|
2018-02-11 23:38:10 +00:00
|
|
|
DWORD Size;
|
2014-05-17 23:49:35 +00:00
|
|
|
|
2014-09-28 16:27:30 +00:00
|
|
|
/* Dump the VM memory */
|
|
|
|
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
|
|
|
|
Buffer = REAL_TO_PHYS(NULL);
|
|
|
|
Size = MAX_ADDRESS - (ULONG_PTR)(NULL);
|
|
|
|
WriteFile(hFile, Buffer, Size, &Size, NULL);
|
|
|
|
}
|
2014-05-17 23:49:35 +00:00
|
|
|
|
2014-09-28 16:27:30 +00:00
|
|
|
static VOID
|
|
|
|
DumpMemoryTxt(HANDLE hFile)
|
|
|
|
{
|
2014-05-17 23:49:35 +00:00
|
|
|
#define LINE_SIZE 75 + 2
|
|
|
|
ULONG i;
|
|
|
|
PBYTE Ptr1, Ptr2;
|
|
|
|
CHAR LineBuffer[LINE_SIZE];
|
|
|
|
PCHAR Line;
|
2018-02-11 23:38:10 +00:00
|
|
|
DWORD LineSize;
|
2014-05-17 23:49:35 +00:00
|
|
|
|
|
|
|
/* Dump the VM memory */
|
|
|
|
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
|
|
|
|
Ptr1 = Ptr2 = REAL_TO_PHYS(NULL);
|
|
|
|
while (MAX_ADDRESS - (ULONG_PTR)PHYS_TO_REAL(Ptr1) > 0)
|
|
|
|
{
|
|
|
|
Ptr1 = Ptr2;
|
|
|
|
Line = LineBuffer;
|
|
|
|
|
|
|
|
/* Print the address */
|
2018-02-11 23:38:10 +00:00
|
|
|
Line += snprintf(Line, LINE_SIZE + LineBuffer - Line, "%08Ix ", (ULONG_PTR)PHYS_TO_REAL(Ptr1));
|
2014-05-17 23:49:35 +00:00
|
|
|
|
|
|
|
/* Print up to 16 bytes... */
|
|
|
|
|
|
|
|
/* ... in hexadecimal form first... */
|
|
|
|
i = 0;
|
|
|
|
while (i++ <= 0x0F && (MAX_ADDRESS - (ULONG_PTR)PHYS_TO_REAL(Ptr1) > 0))
|
|
|
|
{
|
|
|
|
Line += snprintf(Line, LINE_SIZE + LineBuffer - Line, " %02x", *Ptr1);
|
|
|
|
++Ptr1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ... align with spaces if needed... */
|
2016-03-09 00:07:24 +00:00
|
|
|
RtlFillMemory(Line, (0x0F + 2 - i) * 3 + 2, ' ');
|
|
|
|
Line += (0x0F + 2 - i) * 3 + 2;
|
2014-05-17 23:49:35 +00:00
|
|
|
|
|
|
|
/* ... then in character form. */
|
|
|
|
i = 0;
|
|
|
|
while (i++ <= 0x0F && (MAX_ADDRESS - (ULONG_PTR)PHYS_TO_REAL(Ptr2) > 0))
|
|
|
|
{
|
2014-05-17 23:55:14 +00:00
|
|
|
*Line++ = ((*Ptr2 >= 0x20 && *Ptr2 <= 0x7E) || (*Ptr2 >= 0x80 && *Ptr2 < 0xFF) ? *Ptr2 : '.');
|
2014-05-17 23:49:35 +00:00
|
|
|
++Ptr2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Newline */
|
|
|
|
*Line++ = '\r';
|
|
|
|
*Line++ = '\n';
|
|
|
|
|
|
|
|
/* Finally write the line to the file */
|
|
|
|
LineSize = Line - LineBuffer;
|
|
|
|
WriteFile(hFile, LineBuffer, LineSize, &LineSize, NULL);
|
|
|
|
}
|
2014-09-28 16:27:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID DumpMemory(BOOLEAN TextFormat)
|
|
|
|
{
|
|
|
|
static ULONG DumpNumber = 0;
|
|
|
|
|
|
|
|
HANDLE hFile;
|
|
|
|
WCHAR FileName[MAX_PATH];
|
|
|
|
|
|
|
|
/* Build a suitable file name */
|
|
|
|
_snwprintf(FileName, MAX_PATH,
|
|
|
|
L"memdump%lu.%s",
|
|
|
|
DumpNumber,
|
|
|
|
TextFormat ? L"txt" : L"dat");
|
|
|
|
++DumpNumber;
|
|
|
|
|
|
|
|
DPRINT1("Creating memory dump file '%S'...\n", FileName);
|
|
|
|
|
|
|
|
/* Always create the dump file */
|
|
|
|
hFile = CreateFileW(FileName,
|
|
|
|
GENERIC_WRITE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (hFile == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
DPRINT1("Error when creating '%S' for memory dumping, GetLastError() = %u\n",
|
|
|
|
FileName, GetLastError());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Dump the VM memory in the chosen format */
|
|
|
|
if (TextFormat)
|
|
|
|
DumpMemoryTxt(hFile);
|
|
|
|
else
|
|
|
|
DumpMemoryRaw(hFile);
|
2014-05-17 23:49:35 +00:00
|
|
|
|
|
|
|
/* Close the file */
|
|
|
|
CloseHandle(hFile);
|
2014-09-14 00:43:43 +00:00
|
|
|
|
|
|
|
DPRINT1("Memory dump done\n");
|
2014-05-17 23:49:35 +00:00
|
|
|
}
|
|
|
|
|
2015-09-27 15:24:26 +00:00
|
|
|
VOID MountFloppy(IN ULONG DiskNumber)
|
|
|
|
{
|
|
|
|
// FIXME: This should be present in PSDK commdlg.h
|
|
|
|
//
|
|
|
|
// FlagsEx Values
|
|
|
|
#if (_WIN32_WINNT >= 0x0500)
|
|
|
|
#define OFN_EX_NOPLACESBAR 0x00000001
|
|
|
|
#endif // (_WIN32_WINNT >= 0x0500)
|
|
|
|
|
2015-11-07 20:19:32 +00:00
|
|
|
BOOLEAN Success;
|
2015-10-03 02:36:35 +00:00
|
|
|
OPENFILENAMEW ofn;
|
|
|
|
WCHAR szFile[MAX_PATH] = L"";
|
|
|
|
|
|
|
|
ASSERT(DiskNumber < ARRAYSIZE(GlobalSettings.FloppyDisks));
|
2015-09-27 15:24:26 +00:00
|
|
|
|
|
|
|
RtlZeroMemory(&ofn, sizeof(ofn));
|
|
|
|
ofn.lStructSize = sizeof(ofn);
|
|
|
|
ofn.hwndOwner = hConsoleWnd;
|
2015-10-03 02:36:35 +00:00
|
|
|
ofn.lpstrTitle = L"Select a virtual floppy image";
|
2015-09-27 15:24:26 +00:00
|
|
|
ofn.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
|
|
|
// ofn.FlagsEx = OFN_EX_NOPLACESBAR;
|
2015-10-03 02:36:35 +00:00
|
|
|
ofn.lpstrFilter = L"Virtual floppy images (*.vfd;*.img;*.ima;*.dsk)\0*.vfd;*.img;*.ima;*.dsk\0All files (*.*)\0*.*\0\0";
|
|
|
|
ofn.lpstrDefExt = L"vfd";
|
2015-09-27 15:24:26 +00:00
|
|
|
ofn.nFilterIndex = 0;
|
|
|
|
ofn.lpstrFile = szFile;
|
|
|
|
ofn.nMaxFile = ARRAYSIZE(szFile);
|
|
|
|
|
2015-10-03 02:36:35 +00:00
|
|
|
if (!GetOpenFileNameW(&ofn))
|
2015-09-27 15:24:26 +00:00
|
|
|
{
|
|
|
|
DPRINT1("CommDlgExtendedError = %d\n", CommDlgExtendedError());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-03 02:36:35 +00:00
|
|
|
/* Free the old string */
|
|
|
|
if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
|
2015-11-07 20:19:32 +00:00
|
|
|
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
2015-10-03 02:36:35 +00:00
|
|
|
|
2015-11-07 20:19:32 +00:00
|
|
|
/* Reinitialize the string */
|
|
|
|
Success = RtlCreateUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], szFile);
|
|
|
|
ASSERT(Success);
|
2015-09-27 15:24:26 +00:00
|
|
|
|
2015-10-03 02:36:35 +00:00
|
|
|
/* Mount the disk */
|
|
|
|
if (!MountDisk(FLOPPY_DISK, DiskNumber, GlobalSettings.FloppyDisks[DiskNumber].Buffer, !!(ofn.Flags & OFN_READONLY)))
|
|
|
|
{
|
2015-09-27 15:24:26 +00:00
|
|
|
DisplayMessage(L"An error happened when mounting disk %d", DiskNumber);
|
2015-11-07 20:19:32 +00:00
|
|
|
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
|
|
|
RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
|
2015-10-03 02:36:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Refresh the menu state */
|
|
|
|
UpdateVdmMenuDisks();
|
2015-09-27 15:24:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID EjectFloppy(IN ULONG DiskNumber)
|
|
|
|
{
|
2015-10-03 02:36:35 +00:00
|
|
|
ASSERT(DiskNumber < ARRAYSIZE(GlobalSettings.FloppyDisks));
|
2015-09-27 15:24:26 +00:00
|
|
|
|
2015-10-03 02:36:35 +00:00
|
|
|
/* Unmount the disk */
|
2015-09-27 15:24:26 +00:00
|
|
|
if (!UnmountDisk(FLOPPY_DISK, DiskNumber))
|
|
|
|
DisplayMessage(L"An error happened when ejecting disk %d", DiskNumber);
|
2015-10-03 02:36:35 +00:00
|
|
|
|
|
|
|
/* Free the old string */
|
|
|
|
if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
|
|
|
|
{
|
2015-11-07 20:19:32 +00:00
|
|
|
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
|
|
|
RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
|
2015-10-03 02:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Refresh the menu state */
|
|
|
|
UpdateVdmMenuDisks();
|
2015-09-27 15:24:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
VOID EmulatorPause(VOID)
|
|
|
|
{
|
|
|
|
/* Pause the VDM */
|
|
|
|
VDDBlockUserHook();
|
|
|
|
VgaRefreshDisplay();
|
|
|
|
PauseEventThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID EmulatorResume(VOID)
|
|
|
|
{
|
|
|
|
/* Resume the VDM */
|
|
|
|
ResumeEventThread();
|
|
|
|
VgaRefreshDisplay();
|
|
|
|
VDDResumeUserHook();
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID EmulatorTerminate(VOID)
|
|
|
|
{
|
|
|
|
/* Stop the VDM */
|
|
|
|
CpuUnsimulate(); // Halt the CPU
|
|
|
|
VdmRunning = FALSE;
|
|
|
|
}
|
|
|
|
|
2014-01-25 00:21:51 +00:00
|
|
|
BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
|
2013-06-17 00:00:36 +00:00
|
|
|
{
|
2015-09-28 01:36:31 +00:00
|
|
|
USHORT i;
|
|
|
|
|
2015-03-13 17:57:51 +00:00
|
|
|
/* Initialize memory */
|
|
|
|
if (!MemInitialize())
|
2014-11-15 01:35:28 +00:00
|
|
|
{
|
2015-03-13 17:57:51 +00:00
|
|
|
wprintf(L"Memory initialization failed.\n");
|
2014-11-15 01:35:28 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-01-11 20:59:27 +00:00
|
|
|
/* Initialize I/O ports */
|
|
|
|
/* Initialize RAM */
|
2013-06-17 00:00:36 +00:00
|
|
|
|
2014-09-30 23:47:23 +00:00
|
|
|
/* Initialize the CPU */
|
|
|
|
|
2014-02-01 16:32:20 +00:00
|
|
|
/* Initialize the internal clock */
|
|
|
|
if (!ClockInitialize())
|
|
|
|
{
|
|
|
|
wprintf(L"FATAL: Failed to initialize the clock\n");
|
2014-11-17 02:08:12 +00:00
|
|
|
EmulatorCleanup();
|
2014-02-01 16:32:20 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-11-01 01:46:58 +00:00
|
|
|
/* Initialize the CPU */
|
2014-09-30 23:47:23 +00:00
|
|
|
CpuInitialize();
|
2013-06-17 00:00:36 +00:00
|
|
|
|
2014-02-01 16:32:20 +00:00
|
|
|
/* Initialize DMA */
|
2014-11-21 00:22:48 +00:00
|
|
|
DmaInitialize();
|
2014-02-01 16:32:20 +00:00
|
|
|
|
2015-05-14 21:13:07 +00:00
|
|
|
/* Initialize PIC, PIT, CMOS, PC Speaker and PS/2 */
|
2014-01-11 20:59:27 +00:00
|
|
|
PicInitialize();
|
2013-12-17 02:19:52 +00:00
|
|
|
|
2015-05-14 21:13:07 +00:00
|
|
|
PitInitialize();
|
2014-01-28 20:24:24 +00:00
|
|
|
PitSetOutFunction(0, NULL, PitChan0Out);
|
|
|
|
PitSetOutFunction(1, NULL, PitChan1Out);
|
|
|
|
PitSetOutFunction(2, NULL, PitChan2Out);
|
|
|
|
|
2015-05-14 21:13:07 +00:00
|
|
|
CmosInitialize();
|
|
|
|
SpeakerInitialize();
|
|
|
|
PpiInitialize();
|
2014-01-28 20:24:24 +00:00
|
|
|
|
2014-09-16 00:51:15 +00:00
|
|
|
PS2Initialize();
|
|
|
|
|
|
|
|
/* Initialize the keyboard and mouse and connect them to their PS/2 ports */
|
|
|
|
KeyboardInit(0);
|
|
|
|
MouseInit(1);
|
2014-01-25 00:21:51 +00:00
|
|
|
|
2014-05-11 19:25:09 +00:00
|
|
|
/**************** ATTACH INPUT WITH CONSOLE *****************/
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
/* Create the task event */
|
2015-09-24 00:27:59 +00:00
|
|
|
VdmTaskEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
ASSERT(VdmTaskEvent != NULL);
|
|
|
|
|
2014-02-01 16:32:20 +00:00
|
|
|
/* Start the input thread */
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
InputThread = CreateThread(NULL, 0, &ConsoleEventThread, ConsoleInput, 0, NULL);
|
2014-05-11 19:25:09 +00:00
|
|
|
if (InputThread == NULL)
|
|
|
|
{
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
wprintf(L"FATAL: Failed to create the console input thread.\n");
|
2014-11-17 02:08:12 +00:00
|
|
|
EmulatorCleanup();
|
2014-05-11 19:25:09 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-09-24 00:27:59 +00:00
|
|
|
ResumeEventThread();
|
2014-05-11 19:25:09 +00:00
|
|
|
/************************************************************/
|
2014-02-01 16:32:20 +00:00
|
|
|
|
2014-01-25 00:21:51 +00:00
|
|
|
/* Initialize the VGA */
|
2014-05-11 19:25:09 +00:00
|
|
|
if (!VgaInitialize(ConsoleOutput))
|
|
|
|
{
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
wprintf(L"FATAL: Failed to initialize VGA support.\n");
|
2014-11-17 02:08:12 +00:00
|
|
|
EmulatorCleanup();
|
2014-05-11 19:25:09 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-01-25 00:21:51 +00:00
|
|
|
|
2015-09-26 17:35:31 +00:00
|
|
|
/* Initialize the disk controller */
|
|
|
|
if (!DiskCtrlInitialize())
|
|
|
|
{
|
|
|
|
wprintf(L"FATAL: Failed to completely initialize the disk controller.\n");
|
|
|
|
EmulatorCleanup();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-09-28 22:15:06 +00:00
|
|
|
/* Mount the available floppy disks */
|
|
|
|
for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i)
|
|
|
|
{
|
|
|
|
if (GlobalSettings.FloppyDisks[i].Length != 0 &&
|
|
|
|
GlobalSettings.FloppyDisks[i].Buffer &&
|
2019-02-09 04:08:08 +00:00
|
|
|
*GlobalSettings.FloppyDisks[i].Buffer != L'\0')
|
2015-09-28 22:15:06 +00:00
|
|
|
{
|
2015-10-03 02:36:35 +00:00
|
|
|
if (!MountDisk(FLOPPY_DISK, i, GlobalSettings.FloppyDisks[i].Buffer, FALSE))
|
|
|
|
{
|
2015-11-07 20:19:32 +00:00
|
|
|
DPRINT1("Failed to mount floppy disk file '%wZ'.\n", &GlobalSettings.FloppyDisks[i]);
|
|
|
|
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[i]);
|
|
|
|
RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[i], NULL, 0);
|
2015-10-03 02:36:35 +00:00
|
|
|
}
|
2015-09-28 22:15:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-01 00:09:24 +00:00
|
|
|
/*
|
|
|
|
* Mount the available hard disks. Contrary to floppies, failing
|
|
|
|
* mounting a hard disk is considered as an unrecoverable error.
|
|
|
|
*/
|
2015-09-28 01:36:31 +00:00
|
|
|
for (i = 0; i < ARRAYSIZE(GlobalSettings.HardDisks); ++i)
|
|
|
|
{
|
|
|
|
if (GlobalSettings.HardDisks[i].Length != 0 &&
|
|
|
|
GlobalSettings.HardDisks[i].Buffer &&
|
2019-02-09 04:08:08 +00:00
|
|
|
*GlobalSettings.HardDisks[i].Buffer != L'\0')
|
2015-09-28 01:36:31 +00:00
|
|
|
{
|
2015-10-01 00:09:24 +00:00
|
|
|
if (!MountDisk(HARD_DISK, i, GlobalSettings.HardDisks[i].Buffer, FALSE))
|
|
|
|
{
|
2015-11-07 20:19:32 +00:00
|
|
|
wprintf(L"FATAL: Failed to mount hard disk file '%wZ'.\n", &GlobalSettings.HardDisks[i]);
|
2015-10-01 00:09:24 +00:00
|
|
|
EmulatorCleanup();
|
|
|
|
return FALSE;
|
|
|
|
}
|
2015-09-28 01:36:31 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-27 15:24:26 +00:00
|
|
|
|
2015-10-03 02:36:35 +00:00
|
|
|
/* Refresh the menu state */
|
|
|
|
UpdateVdmMenuDisks();
|
|
|
|
|
2014-02-23 16:09:35 +00:00
|
|
|
/* Initialize the software callback system and register the emulator BOPs */
|
2014-09-30 23:47:23 +00:00
|
|
|
InitializeInt32();
|
2014-02-01 16:32:20 +00:00
|
|
|
RegisterBop(BOP_DEBUGGER , EmulatorDebugBreakBop);
|
2014-09-30 23:47:23 +00:00
|
|
|
// RegisterBop(BOP_UNSIMULATE, CpuUnsimulateBop);
|
2013-12-16 23:57:35 +00:00
|
|
|
|
2014-01-11 20:59:27 +00:00
|
|
|
/* Initialize VDD support */
|
|
|
|
VDDSupInitialize();
|
|
|
|
|
2013-06-17 00:00:36 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-11-01 01:46:58 +00:00
|
|
|
VOID EmulatorCleanup(VOID)
|
|
|
|
{
|
2015-09-26 17:35:31 +00:00
|
|
|
DiskCtrlCleanup();
|
|
|
|
|
2014-03-01 20:58:42 +00:00
|
|
|
VgaCleanup();
|
2014-02-01 16:32:20 +00:00
|
|
|
|
|
|
|
/* Close the input thread handle */
|
|
|
|
if (InputThread != NULL) CloseHandle(InputThread);
|
|
|
|
InputThread = NULL;
|
|
|
|
|
[NTVDM]
- Add support for DOS VDM reentry, i.e. the fact that a DOS app can start a 32-bit app, which in turn can start another DOS app, ad infinitum...
CORE-9711 CORE-9773 #resolve
- Add a small COMMAND.COM which is, for now, completely included in NTVDM. This COMMAND.COM is needed in order to support reentrancy. The fact that I chose to put it inside NTVDM is that any user can use instead his/her own COMMAND.COM, while retaining the possibility to perform VDM reentrancy (on Windows, if you remove the COMMAND.COM in windows\system32 and replace it with your own, you will break VDM reentrancy on windows' ntvdm).
CORE-5221 #resolve #comment I choose for the moment an internal COMMAND.COM, but you can recompile NTVDM to use it externally instead.
Global remarks:
- Quite a few DPRINTs were added for diagnostic purposes (since DOS reentrancy is a new feature), to be sure everything behaves as expected when being used with a large panel of applications. They will be removed when everything is OK.
- Support for current directories and 16/32-bit environment translation (in ntvdm + basevdm-side) remain to be implemented.
Other changes:
- Improve a bit the VDM shutdown code by gathering it at one place (there's still room for other improvements).
- Add suppport for properly pausing/resuming NTVDM.
- Bufferize some console events before dispatching.
Have fun ;^)
svn path=/trunk/; revision=69204
2015-09-12 20:09:25 +00:00
|
|
|
/* Close the task event */
|
|
|
|
if (VdmTaskEvent != NULL) CloseHandle(VdmTaskEvent);
|
|
|
|
VdmTaskEvent = NULL;
|
|
|
|
|
2014-01-25 00:21:51 +00:00
|
|
|
PS2Cleanup();
|
|
|
|
|
2014-01-11 20:59:27 +00:00
|
|
|
SpeakerCleanup();
|
|
|
|
CmosCleanup();
|
|
|
|
// PitCleanup();
|
|
|
|
// PicCleanup();
|
2014-11-21 00:22:48 +00:00
|
|
|
|
|
|
|
// DmaCleanup();
|
2014-01-11 20:59:27 +00:00
|
|
|
|
2014-09-30 23:47:23 +00:00
|
|
|
CpuCleanup();
|
2015-03-13 17:57:51 +00:00
|
|
|
MemCleanup();
|
2013-11-01 01:46:58 +00:00
|
|
|
}
|
|
|
|
|
2013-06-26 17:15:45 +00:00
|
|
|
|
2013-08-31 19:18:12 +00:00
|
|
|
|
2014-02-01 16:32:20 +00:00
|
|
|
VOID
|
|
|
|
WINAPI
|
|
|
|
VDDSimulate16(VOID)
|
2013-06-26 17:15:45 +00:00
|
|
|
{
|
2014-09-30 23:47:23 +00:00
|
|
|
CpuSimulate();
|
2013-06-26 17:15:45 +00:00
|
|
|
}
|
|
|
|
|
2013-12-24 15:52:31 +00:00
|
|
|
VOID
|
|
|
|
WINAPI
|
|
|
|
VDDTerminateVDM(VOID)
|
|
|
|
{
|
|
|
|
/* Stop the VDM */
|
2014-03-02 14:37:51 +00:00
|
|
|
EmulatorTerminate();
|
2013-12-24 15:52:31 +00:00
|
|
|
}
|
|
|
|
|
2013-06-17 00:00:36 +00:00
|
|
|
/* EOF */
|