mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
[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). svn path=/trunk/; revision=67726
This commit is contained in:
parent
b4e859a232
commit
6b9a175dfb
11 changed files with 126 additions and 52 deletions
|
@ -24,6 +24,7 @@ list(APPEND SOURCE
|
||||||
hardware/mouse.c
|
hardware/mouse.c
|
||||||
hardware/pic.c
|
hardware/pic.c
|
||||||
hardware/pit.c
|
hardware/pit.c
|
||||||
|
hardware/ppi.c
|
||||||
hardware/ps2.c
|
hardware/ps2.c
|
||||||
hardware/sound/speaker.c
|
hardware/sound/speaker.c
|
||||||
hardware/video/vga.c
|
hardware/video/vga.c
|
||||||
|
|
|
@ -454,7 +454,6 @@ static VOID WINAPI BiosRomBasic(LPWORD Stack)
|
||||||
|
|
||||||
/* Stop the VDM */
|
/* Stop the VDM */
|
||||||
EmulatorTerminate();
|
EmulatorTerminate();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ Quit:
|
||||||
{
|
{
|
||||||
/* We failed everything, stop the VDM */
|
/* We failed everything, stop the VDM */
|
||||||
EmulatorTerminate();
|
EmulatorTerminate();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -28,9 +28,10 @@
|
||||||
#include "hardware/keyboard.h"
|
#include "hardware/keyboard.h"
|
||||||
#include "hardware/mouse.h"
|
#include "hardware/mouse.h"
|
||||||
#include "hardware/pic.h"
|
#include "hardware/pic.h"
|
||||||
|
#include "hardware/pit.h"
|
||||||
|
#include "hardware/ppi.h"
|
||||||
#include "hardware/ps2.h"
|
#include "hardware/ps2.h"
|
||||||
#include "hardware/sound/speaker.h"
|
#include "hardware/sound/speaker.h"
|
||||||
#include "hardware/pit.h"
|
|
||||||
#include "hardware/video/vga.h"
|
#include "hardware/video/vga.h"
|
||||||
|
|
||||||
#include "vddsup.h"
|
#include "vddsup.h"
|
||||||
|
@ -41,8 +42,7 @@
|
||||||
LPVOID BaseAddress = NULL;
|
LPVOID BaseAddress = NULL;
|
||||||
BOOLEAN VdmRunning = TRUE;
|
BOOLEAN VdmRunning = TRUE;
|
||||||
|
|
||||||
static BOOLEAN A20Line = FALSE;
|
static BOOLEAN A20Line = FALSE;
|
||||||
static BYTE Port61hState = 0x00;
|
|
||||||
|
|
||||||
static HANDLE InputThread = NULL;
|
static HANDLE InputThread = NULL;
|
||||||
|
|
||||||
|
@ -149,7 +149,6 @@ VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack)
|
||||||
|
|
||||||
/* Stop the VDM */
|
/* Stop the VDM */
|
||||||
EmulatorTerminate();
|
EmulatorTerminate();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID EmulatorTerminate(VOID)
|
VOID EmulatorTerminate(VOID)
|
||||||
|
@ -181,36 +180,6 @@ static VOID WINAPI EmulatorDebugBreakBop(LPWORD Stack)
|
||||||
DebugBreak();
|
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)
|
static VOID WINAPI PitChan0Out(LPVOID Param, BOOLEAN State)
|
||||||
{
|
{
|
||||||
if (State)
|
if (State)
|
||||||
|
@ -466,21 +435,18 @@ BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
|
||||||
/* Initialize DMA */
|
/* Initialize DMA */
|
||||||
DmaInitialize();
|
DmaInitialize();
|
||||||
|
|
||||||
/* Initialize the PIC, the PIT, the CMOS and the PC Speaker */
|
/* Initialize PIC, PIT, CMOS, PC Speaker and PS/2 */
|
||||||
PicInitialize();
|
PicInitialize();
|
||||||
PitInitialize();
|
|
||||||
CmosInitialize();
|
|
||||||
SpeakerInitialize();
|
|
||||||
|
|
||||||
/* Set output functions */
|
PitInitialize();
|
||||||
PitSetOutFunction(0, NULL, PitChan0Out);
|
PitSetOutFunction(0, NULL, PitChan0Out);
|
||||||
PitSetOutFunction(1, NULL, PitChan1Out);
|
PitSetOutFunction(1, NULL, PitChan1Out);
|
||||||
PitSetOutFunction(2, NULL, PitChan2Out);
|
PitSetOutFunction(2, NULL, PitChan2Out);
|
||||||
|
|
||||||
/* Register the I/O Ports */
|
CmosInitialize();
|
||||||
RegisterIoPort(CONTROL_SYSTEM_PORT61H, Port61hRead, Port61hWrite);
|
SpeakerInitialize();
|
||||||
|
PpiInitialize();
|
||||||
|
|
||||||
/* Initialize the PS/2 port */
|
|
||||||
PS2Initialize();
|
PS2Initialize();
|
||||||
|
|
||||||
/* Initialize the keyboard and mouse and connect them to their PS/2 ports */
|
/* Initialize the keyboard and mouse and connect them to their PS/2 ports */
|
||||||
|
|
|
@ -71,10 +71,6 @@ BCD_TO_BINARY(USHORT Value)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* System I/O ports */
|
|
||||||
#define CONTROL_SYSTEM_PORT61H 0x61
|
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
EMULATOR_EXCEPTION_DIVISION_BY_ZERO,
|
EMULATOR_EXCEPTION_DIVISION_BY_ZERO,
|
||||||
|
|
85
reactos/subsystems/mvdm/ntvdm/hardware/ppi.c
Normal file
85
reactos/subsystems/mvdm/ntvdm/hardware/ppi.c
Normal file
|
@ -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 */
|
26
reactos/subsystems/mvdm/ntvdm/hardware/ppi.h
Normal file
26
reactos/subsystems/mvdm/ntvdm/hardware/ppi.h
Normal file
|
@ -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 */
|
|
@ -201,7 +201,7 @@ static VOID WINAPI PS2WritePort(USHORT Port, BYTE Data)
|
||||||
{
|
{
|
||||||
/* Stop the VDM */
|
/* Stop the VDM */
|
||||||
EmulatorTerminate();
|
EmulatorTerminate();
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,6 +230,7 @@ static VOID WINAPI PS2WritePort(USHORT Port, BYTE Data)
|
||||||
{
|
{
|
||||||
/* CPU disabled - Stop the VDM */
|
/* CPU disabled - Stop the VDM */
|
||||||
EmulatorTerminate();
|
EmulatorTerminate();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the A20 line setting */
|
/* Update the A20 line setting */
|
||||||
|
|
|
@ -14,9 +14,6 @@
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
/* Extra PSDK/NDK Headers */
|
|
||||||
#include <ndk/mmfuncs.h>
|
|
||||||
|
|
||||||
/* PRIVATE VARIABLES **********************************************************/
|
/* PRIVATE VARIABLES **********************************************************/
|
||||||
|
|
||||||
typedef struct _MEM_HOOK
|
typedef struct _MEM_HOOK
|
||||||
|
|
|
@ -542,7 +542,8 @@ Cleanup:
|
||||||
|
|
||||||
/* Quit the VDM */
|
/* Quit the VDM */
|
||||||
DPRINT1("\n\n\nNTVDM - Exiting...\n\n\n");
|
DPRINT1("\n\n\nNTVDM - Exiting...\n\n\n");
|
||||||
|
/* Some VDDs rely on the fact that NTVDM calls ExitProcess on Windows */
|
||||||
|
ExitProcess(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ DWORD WINAPI SetLastConsoleEventActive(VOID);
|
||||||
|
|
||||||
#define NTOS_MODE_USER
|
#define NTOS_MODE_USER
|
||||||
#include <ndk/kefuncs.h>
|
#include <ndk/kefuncs.h>
|
||||||
|
#include <ndk/mmfuncs.h>
|
||||||
#include <ndk/obfuncs.h>
|
#include <ndk/obfuncs.h>
|
||||||
#include <ndk/rtlfuncs.h>
|
#include <ndk/rtlfuncs.h>
|
||||||
#include <ndk/rtltypes.h>
|
#include <ndk/rtltypes.h>
|
||||||
|
|
Loading…
Reference in a new issue