- 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:
Aleksandar Andrejevic 2015-04-17 18:36:45 +00:00
parent 22d1251dbc
commit 2dc91ac6c0
5 changed files with 36 additions and 51 deletions

View file

@ -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);

View file

@ -39,7 +39,7 @@
// #define WORKING_TIMER
/* Processor speed */
#define STEPS_PER_CYCLE 256
#define STEPS_PER_CYCLE 1024
/* VARIABLES ******************************************************************/

View file

@ -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 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;
}
/* 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);
case 1:
{
Packet.HorzCounter = IOReadB(PS2_DATA_PORT);
break;
}
/* Adjust the sign */
if (Flags & MOUSE_X_SIGN) DeltaX = -DeltaX;
if (Flags & MOUSE_Y_SIGN) DeltaY = -DeltaY;
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;
}
/* 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 @@ 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);
}
}

View file

@ -208,6 +208,7 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
}
DataByteWait = 0;
return;
}
/* Check if we're in wrap mode */

View file

@ -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;
}