mirror of
https://github.com/reactos/reactos.git
synced 2025-05-07 18:56:48 +00:00
[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. svn path=/trunk/; revision=67231
This commit is contained in:
parent
22d1251dbc
commit
2dc91ac6c0
5 changed files with 36 additions and 51 deletions
|
@ -110,6 +110,24 @@ VOID BiosMousePs2Interface(LPWORD Stack)
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
// #define WORKING_TIMER
|
||||
|
||||
/* Processor speed */
|
||||
#define STEPS_PER_CYCLE 256
|
||||
#define STEPS_PER_CYCLE 1024
|
||||
|
||||
/* VARIABLES ******************************************************************/
|
||||
|
||||
|
|
|
@ -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,51 +287,26 @@ static inline VOID DosUpdateButtons(BYTE ButtonState)
|
|||
|
||||
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;
|
||||
/* 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 (Packet.Flags & MOUSE_X_SIGN) DeltaX = -DeltaX;
|
||||
if (Packet.Flags & MOUSE_Y_SIGN) DeltaY = -DeltaY;
|
||||
if (Flags & MOUSE_X_SIGN) DeltaX = -DeltaX;
|
||||
if (Flags & MOUSE_Y_SIGN) DeltaY = -DeltaY;
|
||||
|
||||
/* Update the counters */
|
||||
DriverState.HorizCount += DeltaX;
|
||||
DriverState.VertCount += DeltaY;
|
||||
|
||||
ByteCounter = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the absolute position directly from the mouse, this is the only
|
||||
* way to perfectly synchronize the host and guest mouse pointer.
|
||||
|
@ -834,13 +807,6 @@ VOID DosMouseEnable(VOID)
|
|||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -208,6 +208,7 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
|||
}
|
||||
|
||||
DataByteWait = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if we're in wrap mode */
|
||||
|
|
|
@ -42,7 +42,7 @@ typedef struct _PS2_PORT
|
|||
#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 @@ BOOLEAN PS2Initialize(VOID)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue