Author: aandrejevic
Date: Fri Apr 17 18:36:45 2015
New Revision: 67231
URL:
http://svn.reactos.org/svn/reactos?rev=67231&view=rev
Log:
[NTVDM]
- The auxiliary PS/2 port IRQ is disabled by default.
- In the DOS mouse driver's IRQ handler, just reading the entire packet
is faster than waiting for one IRQ per byte. (real drivers can do that too,
using polling, which is slower on real hardware but faster in NTVDM).
- Increase the speed of the PS/2 IRQ scheduler so that mouse packets don't
fill up the queue completely. And consequently, increase the number of
CPU steps per cycle to avoid "stuck key" bugs.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c
trunk/reactos/subsystems/mvdm/ntvdm/clock.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c
trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c
trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c [iso-8859-1] Fri Apr 17
18:36:45 2015
@@ -110,6 +110,24 @@
BOOLEAN MouseBios32Initialize(VOID)
{
+ BYTE ControllerConfig;
+
+ /* Clear the mouse queue */
+ while (PS2PortQueueRead(1)) continue;
+
+ /* Enable packet reporting */
+ IOWriteB(PS2_CONTROL_PORT, 0xD4);
+ IOWriteB(PS2_DATA_PORT, 0xF4);
+
+ /* Read the mouse ACK reply */
+ PS2PortQueueRead(1);
+
+ /* Enable IRQ12 */
+ IOWriteB(PS2_CONTROL_PORT, 0x20);
+ ControllerConfig = IOReadB(PS2_DATA_PORT);
+ IOWriteB(PS2_CONTROL_PORT, 0x60);
+ IOWriteB(PS2_DATA_PORT, ControllerConfig | 0x02);
+
/* Set up the HW vector interrupts */
EnableHwIRQ(12, BiosMouseIrq);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/clock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/cloc…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/clock.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/clock.c [iso-8859-1] Fri Apr 17 18:36:45 2015
@@ -39,7 +39,7 @@
// #define WORKING_TIMER
/* Processor speed */
-#define STEPS_PER_CYCLE 256
+#define STEPS_PER_CYCLE 1024
/* VARIABLES ******************************************************************/
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c [iso-8859-1] Fri Apr 17 18:36:45
2015
@@ -30,8 +30,6 @@
#define MICKEYS_PER_CELL_HORIZ 8
#define MICKEYS_PER_CELL_VERT 16
-static MOUSE_PACKET Packet;
-static INT ByteCounter = 0;
static BOOLEAN DriverEnabled = FALSE;
static MOUSE_DRIVER_STATE DriverState;
static DWORD OldIrqHandler;
@@ -289,50 +287,25 @@
static VOID WINAPI DosMouseIrq(LPWORD Stack)
{
+ BYTE Flags;
+ SHORT DeltaX, DeltaY;
COORD Position;
BYTE ButtonState;
- switch (ByteCounter)
- {
- case 0:
- {
- Packet.Flags = IOReadB(PS2_DATA_PORT);
- break;
- }
-
- case 1:
- {
- Packet.HorzCounter = IOReadB(PS2_DATA_PORT);
- break;
- }
-
- case 2:
- {
- Packet.VertCounter = IOReadB(PS2_DATA_PORT);
- break;
- }
-
- default:
- {
- /* Shouldn't happen */
- ASSERT(FALSE);
- }
- }
-
- if (++ByteCounter == 3)
- {
- SHORT DeltaX = Packet.HorzCounter;
- SHORT DeltaY = Packet.VertCounter;
-
- /* Adjust the sign */
- if (Packet.Flags & MOUSE_X_SIGN) DeltaX = -DeltaX;
- if (Packet.Flags & MOUSE_Y_SIGN) DeltaY = -DeltaY;
-
- DriverState.HorizCount += DeltaX;
- DriverState.VertCount += DeltaY;
-
- ByteCounter = 0;
- }
+ /* Read the whole packet at once */
+ Flags = IOReadB(PS2_DATA_PORT);
+ PS2PortQueueRead(1);
+ DeltaX = IOReadB(PS2_DATA_PORT);
+ PS2PortQueueRead(1);
+ DeltaY = IOReadB(PS2_DATA_PORT);
+
+ /* Adjust the sign */
+ if (Flags & MOUSE_X_SIGN) DeltaX = -DeltaX;
+ if (Flags & MOUSE_Y_SIGN) DeltaY = -DeltaY;
+
+ /* Update the counters */
+ DriverState.HorizCount += DeltaX;
+ DriverState.VertCount += DeltaY;
/*
* Get the absolute position directly from the mouse, this is the only
@@ -834,13 +807,6 @@
/* Set the IRQ handler */
RegisterDosInt32(MOUSE_IRQ_INT, DosMouseIrq);
-
- /* Enable packet reporting */
- IOWriteB(PS2_CONTROL_PORT, 0xD4);
- IOWriteB(PS2_DATA_PORT, 0xF4);
-
- /* Read the mouse ACK reply */
- PS2PortQueueRead(1);
}
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c [iso-8859-1] Fri Apr 17 18:36:45
2015
@@ -208,6 +208,7 @@
}
DataByteWait = 0;
+ return;
}
/* Check if we're in wrap mode */
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c [iso-8859-1] Fri Apr 17 18:36:45
2015
@@ -42,7 +42,7 @@
#define PS2_PORTS 2
static PS2_PORT Ports[PS2_PORTS];
-#define PS2_DEFAULT_CONFIG 0x47
+#define PS2_DEFAULT_CONFIG 0x45
static BYTE ControllerConfig = PS2_DEFAULT_CONFIG;
static BYTE ControllerCommand = 0x00;
@@ -405,7 +405,7 @@
RegisterIoPort(PS2_CONTROL_PORT, PS2ReadPort, PS2WritePort);
RegisterIoPort(PS2_DATA_PORT , PS2ReadPort, PS2WritePort);
- IrqTimer = CreateHardwareTimer(HARDWARE_TIMER_ONESHOT, 20, GeneratePS2Irq);
+ IrqTimer = CreateHardwareTimer(HARDWARE_TIMER_ONESHOT, 10, GeneratePS2Irq);
return TRUE;
}