Author: hbelusca Date: Thu May 14 21:13:07 2015 New Revision: 67726
URL: http://svn.reactos.org/svn/reactos?rev=67726&view=rev Log: [NTVDM] - Add some early "return" after calls to EmulatorTerminate() - Some VDDs rely on the fact that NTVDM calls ExitProcess on Windows when it is going to quit, so let's do the same. - Put port 61h (and 62h) support in ppi.c (programmable-peripheral-interface).
Added: trunk/reactos/subsystems/mvdm/ntvdm/hardware/ppi.c (with props) trunk/reactos/subsystems/mvdm/ntvdm/hardware/ppi.h (with props) Modified: trunk/reactos/subsystems/mvdm/ntvdm/CMakeLists.txt trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c trunk/reactos/subsystems/mvdm/ntvdm/emulator.c trunk/reactos/subsystems/mvdm/ntvdm/emulator.h trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c trunk/reactos/subsystems/mvdm/ntvdm/memory.c trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h
Modified: trunk/reactos/subsystems/mvdm/ntvdm/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/CMake... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/CMakeLists.txt [iso-8859-1] Thu May 14 21:13:07 2015 @@ -24,6 +24,7 @@ hardware/mouse.c hardware/pic.c hardware/pit.c + hardware/ppi.c hardware/ps2.c hardware/sound/speaker.c hardware/video/vga.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios/... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c [iso-8859-1] Thu May 14 21:13:07 2015 @@ -454,7 +454,6 @@
/* Stop the VDM */ EmulatorTerminate(); - return; }
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c [iso-8859-1] Thu May 14 21:13:07 2015 @@ -78,6 +78,7 @@ { /* We failed everything, stop the VDM */ EmulatorTerminate(); + return; }
break;
Modified: trunk/reactos/subsystems/mvdm/ntvdm/emulator.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/emula... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/emulator.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/emulator.c [iso-8859-1] Thu May 14 21:13:07 2015 @@ -28,9 +28,10 @@ #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/pit.h" #include "hardware/video/vga.h"
#include "vddsup.h" @@ -41,8 +42,7 @@ LPVOID BaseAddress = NULL; BOOLEAN VdmRunning = TRUE;
-static BOOLEAN A20Line = FALSE; -static BYTE Port61hState = 0x00; +static BOOLEAN A20Line = FALSE;
static HANDLE InputThread = NULL;
@@ -149,7 +149,6 @@
/* Stop the VDM */ EmulatorTerminate(); - return; }
VOID EmulatorTerminate(VOID) @@ -179,36 +178,6 @@ { DPRINT1("NTVDM: BOP_DEBUGGER\n"); DebugBreak(); -} - -static BYTE WINAPI Port61hRead(USHORT Port) -{ - return Port61hState; -} - -static VOID WINAPI Port61hWrite(USHORT Port, BYTE Data) -{ - // BOOLEAN SpeakerStateChange = FALSE; - BYTE OldPort61hState = Port61hState; - - /* Only the four lowest bytes can be written */ - Port61hState = (Port61hState & 0xF0) | (Data & 0x0F); - - if ((OldPort61hState ^ Port61hState) & 0x01) - { - DPRINT("PIT 2 Gate %s\n", Port61hState & 0x01 ? "on" : "off"); - PitSetGate(2, !!(Port61hState & 0x01)); - // SpeakerStateChange = TRUE; - } - - if ((OldPort61hState ^ Port61hState) & 0x02) - { - /* There were some change for the speaker... */ - DPRINT("Speaker %s\n", Port61hState & 0x02 ? "on" : "off"); - // SpeakerStateChange = TRUE; - } - // if (SpeakerStateChange) SpeakerChange(Port61hState); - SpeakerChange(Port61hState); }
static VOID WINAPI PitChan0Out(LPVOID Param, BOOLEAN State) @@ -466,21 +435,18 @@ /* Initialize DMA */ DmaInitialize();
- /* Initialize the PIC, the PIT, the CMOS and the PC Speaker */ + /* Initialize PIC, PIT, CMOS, PC Speaker and PS/2 */ PicInitialize(); + PitInitialize(); - CmosInitialize(); - SpeakerInitialize(); - - /* Set output functions */ PitSetOutFunction(0, NULL, PitChan0Out); PitSetOutFunction(1, NULL, PitChan1Out); PitSetOutFunction(2, NULL, PitChan2Out);
- /* Register the I/O Ports */ - RegisterIoPort(CONTROL_SYSTEM_PORT61H, Port61hRead, Port61hWrite); - - /* Initialize the PS/2 port */ + CmosInitialize(); + SpeakerInitialize(); + PpiInitialize(); + PS2Initialize();
/* Initialize the keyboard and mouse and connect them to their PS/2 ports */
Modified: trunk/reactos/subsystems/mvdm/ntvdm/emulator.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/emula... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/emulator.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/emulator.h [iso-8859-1] Thu May 14 21:13:07 2015 @@ -71,10 +71,6 @@ return Result; }
-/* System I/O ports */ -#define CONTROL_SYSTEM_PORT61H 0x61 - - enum { EMULATOR_EXCEPTION_DIVISION_BY_ZERO,
Added: trunk/reactos/subsystems/mvdm/ntvdm/hardware/ppi.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hardw... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/ppi.c (added) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/ppi.c [iso-8859-1] Thu May 14 21:13:07 2015 @@ -0,0 +1,85 @@ +/* + * COPYRIGHT: GPL - See COPYING in the top level directory + * PROJECT: ReactOS Virtual DOS Machine + * FILE: ppi.c + * PURPOSE: Programmable Peripheral Interface emulation - + * i8255A-5 compatible + * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr) + * + * NOTES: - Most of its functionality as keyboard controller is replaced + * by the PS/2 controller. + * - This controller is here only for having ports 61h and 62h working. + */ + +/* INCLUDES *******************************************************************/ + +#define NDEBUG + +#include "ntvdm.h" +#include "emulator.h" +#include "ppi.h" + +#include "hardware/pit.h" +#include "hardware/sound/speaker.h" + +#include "io.h" + +/* PRIVATE VARIABLES **********************************************************/ + +/*static*/ BYTE Port61hState = 0x00; // Used in emulator.c +static BYTE Port62hState = 0x00; + +/* PRIVATE FUNCTIONS **********************************************************/ + +static BYTE WINAPI PpiReadPort(USHORT Port) +{ + if (Port == PPI_PORT_61H) + return Port61hState; + else if (Port == PPI_PORT_62H) + return Port62hState; + + return 0x00; +} + +static VOID WINAPI Port61hWrite(USHORT Port, BYTE Data) +{ + // BOOLEAN SpeakerStateChange = FALSE; + BYTE OldPort61hState = Port61hState; + + /* Only the four lowest bytes can be written */ + Port61hState = (Port61hState & 0xF0) | (Data & 0x0F); + + if ((OldPort61hState ^ Port61hState) & 0x01) + { + DPRINT("PIT 2 Gate %s\n", Port61hState & 0x01 ? "on" : "off"); + PitSetGate(2, !!(Port61hState & 0x01)); + // SpeakerStateChange = TRUE; + } + + if ((OldPort61hState ^ Port61hState) & 0x02) + { + /* There were some change for the speaker... */ + DPRINT("Speaker %s\n", Port61hState & 0x02 ? "on" : "off"); + // SpeakerStateChange = TRUE; + } + // if (SpeakerStateChange) SpeakerChange(Port61hState); + SpeakerChange(Port61hState); +} + +static VOID WINAPI Port62hWrite(USHORT Port, BYTE Data) +{ + Port62hState = Data; +} + +/* PUBLIC FUNCTIONS ***********************************************************/ + +VOID PpiInitialize(VOID) +{ + /* Register the I/O Ports */ + // Port 0x60 is now used by the PS/2 controller + RegisterIoPort(PPI_PORT_61H, PpiReadPort, Port61hWrite); + RegisterIoPort(PPI_PORT_62H, PpiReadPort, Port62hWrite); + // Port 0x63 is unused +} + +/* EOF */
Propchange: trunk/reactos/subsystems/mvdm/ntvdm/hardware/ppi.c ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/reactos/subsystems/mvdm/ntvdm/hardware/ppi.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hardw... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/ppi.h (added) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/ppi.h [iso-8859-1] Thu May 14 21:13:07 2015 @@ -0,0 +1,26 @@ +/* + * COPYRIGHT: GPL - See COPYING in the top level directory + * PROJECT: ReactOS Virtual DOS Machine + * FILE: ppi.h + * PURPOSE: Programmable Peripheral Interface emulation - + * i8255A-5 compatible + * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr) + */ + +#ifndef _PPI_H_ +#define _PPI_H_ + +/* DEFINES ********************************************************************/ + +#define PPI_PORT_61H 0x61 +#define PPI_PORT_62H 0x62 + +extern BYTE Port61hState; + +/* FUNCTIONS ******************************************************************/ + +VOID PpiInitialize(VOID); + +#endif // _PPI_H_ + +/* EOF */
Propchange: trunk/reactos/subsystems/mvdm/ntvdm/hardware/ppi.h ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hardw... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c [iso-8859-1] Thu May 14 21:13:07 2015 @@ -201,7 +201,7 @@ { /* Stop the VDM */ EmulatorTerminate(); - break; + return; } } } @@ -230,6 +230,7 @@ { /* CPU disabled - Stop the VDM */ EmulatorTerminate(); + return; }
/* Update the A20 line setting */
Modified: trunk/reactos/subsystems/mvdm/ntvdm/memory.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/memor... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/memory.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/memory.c [iso-8859-1] Thu May 14 21:13:07 2015 @@ -13,9 +13,6 @@ #include "ntvdm.h" #include "emulator.h" #include "memory.h" - -/* Extra PSDK/NDK Headers */ -#include <ndk/mmfuncs.h>
/* PRIVATE VARIABLES **********************************************************/
Modified: trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/ntvdm... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c [iso-8859-1] Thu May 14 21:13:07 2015 @@ -542,7 +542,8 @@
/* Quit the VDM */ DPRINT1("\n\n\nNTVDM - Exiting...\n\n\n"); - + /* Some VDDs rely on the fact that NTVDM calls ExitProcess on Windows */ + ExitProcess(0); return 0; }
Modified: trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/ntvdm... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h [iso-8859-1] Thu May 14 21:13:07 2015 @@ -35,6 +35,7 @@
#define NTOS_MODE_USER #include <ndk/kefuncs.h> +#include <ndk/mmfuncs.h> #include <ndk/obfuncs.h> #include <ndk/rtlfuncs.h> #include <ndk/rtltypes.h>