- Add some missing MouseResetCounters calls when enabling/disabling mouse reporting, and an ACKnowledge signal when we set mouse defaults.
- When we have few R/W IO port handlers, just register them directly instead of using a wrap-up function.

svn path=/trunk/; revision=68709
This commit is contained in:
Hermès Bélusca-Maïto
2015-08-13 17:20:04 +00:00
parent dbfe940f2d
commit a48e2d06aa
6 changed files with 83 additions and 101 deletions
+14 -10
View File
@@ -29,7 +29,7 @@ static MOUSE_MODE Mode, PreviousMode;
static COORD Position;
static BYTE Resolution; /* Completely ignored */
static BOOLEAN Scaling; /* Completely ignored */
static BOOLEAN Reporting;
static BOOLEAN Reporting = FALSE;
static BYTE MouseId;
static ULONG ButtonState;
static SHORT HorzCounter;
@@ -72,12 +72,6 @@ static VOID MouseReset(VOID)
Mode = MOUSE_STREAMING_MODE;
MouseId = 0;
ScrollMagicCounter = ExtraButtonMagicCounter = 0;
PS2QueuePush(PS2Port, MOUSE_ACK);
/* Send the Basic Assurance Test success code and the device ID */
PS2QueuePush(PS2Port, MOUSE_BAT_SUCCESS);
PS2QueuePush(PS2Port, MouseId);
}
static VOID MouseGetPacket(PMOUSE_PACKET Packet)
@@ -131,7 +125,7 @@ static VOID MouseGetPacket(PMOUSE_PACKET Packet)
if (MouseId >= 3)
{
/* Set the scroll counter */
Packet->Extra |= (UCHAR)ScrollCounter & 0x0F;
Packet->Extra |= ((UCHAR)ScrollCounter & 0x0F);
}
/* Store the counters in the packet */
@@ -262,7 +256,7 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
{
BYTE Status = ButtonState & 7;
if (Scaling) Status |= 1 << 4;
if (Scaling) Status |= 1 << 4;
if (Reporting) Status |= 1 << 5;
if (Mode == MOUSE_REMOTE_MODE) Status |= 1 << 6;
@@ -348,6 +342,7 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
case 0xF4:
{
Reporting = TRUE;
MouseResetCounters();
PS2QueuePush(PS2Port, MOUSE_ACK);
break;
}
@@ -356,6 +351,7 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
case 0xF5:
{
Reporting = FALSE;
MouseResetCounters();
PS2QueuePush(PS2Port, MOUSE_ACK);
break;
}
@@ -366,6 +362,7 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
/* Reset the configuration and counters */
MouseResetConfig();
MouseResetCounters();
PS2QueuePush(PS2Port, MOUSE_ACK);
break;
}
@@ -380,7 +377,14 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
/* Reset */
case 0xFF:
{
/* Send ACKnowledge */
PS2QueuePush(PS2Port, MOUSE_ACK);
MouseReset();
/* Send the Basic Assurance Test success code and the device ID */
PS2QueuePush(PS2Port, MOUSE_BAT_SUCCESS);
PS2QueuePush(PS2Port, MouseId);
break;
}
@@ -428,7 +432,7 @@ VOID MouseEventHandler(PMOUSE_EVENT_RECORD MouseEvent)
}
/* Adjust for double vision */
if (DoubleWidth) NewPosition.X /= 2;
if (DoubleWidth) NewPosition.X /= 2;
if (DoubleHeight) NewPosition.Y /= 2;
WaitForSingleObject(MouseMutex, INFINITE);
@@ -41,9 +41,9 @@
* scroll wheels can't be used at the same time.
*/
#define MOUSE_SCROLL_UP 1
#define MOUSE_SCROLL_DOWN -1
#define MOUSE_SCROLL_DOWN -1
#define MOUSE_SCROLL_RIGHT 2
#define MOUSE_SCROLL_LEFT -2
#define MOUSE_SCROLL_LEFT -2
typedef enum _MOUSE_MODE
{
+62 -69
View File
@@ -19,17 +19,34 @@
/* PRIVATE VARIABLES **********************************************************/
typedef struct _PIC
{
BOOLEAN Initialization;
BYTE MaskRegister;
BYTE IntRequestRegister;
BYTE InServiceRegister;
BYTE IntOffset;
BYTE ConfigRegister;
BYTE CascadeRegister;
BOOLEAN CascadeRegisterSet;
BOOLEAN AutoEoi;
BOOLEAN Slave;
BOOLEAN ReadIsr;
} PIC, *PPIC;
static PIC MasterPic, SlavePic;
/* PRIVATE FUNCTIONS **********************************************************/
static BYTE PicReadCommand(BYTE Port)
static BYTE WINAPI PicReadCommand(USHORT Port)
{
PPIC Pic;
/* Which PIC are we accessing? */
if (Port == PIC_MASTER_CMD) Pic = &MasterPic;
else Pic = &SlavePic;
if (Port == PIC_MASTER_CMD)
Pic = &MasterPic;
else // if (Port == PIC_SLAVE_CMD)
Pic = &SlavePic;
if (Pic->ReadIsr)
{
@@ -44,28 +61,30 @@ static BYTE PicReadCommand(BYTE Port)
}
}
static VOID PicWriteCommand(BYTE Port, BYTE Value)
static VOID WINAPI PicWriteCommand(USHORT Port, BYTE Data)
{
PPIC Pic;
/* Which PIC are we accessing? */
if (Port == PIC_MASTER_CMD) Pic = &MasterPic;
else Pic = &SlavePic;
if (Port == PIC_MASTER_CMD)
Pic = &MasterPic;
else // if (Port == PIC_SLAVE_CMD)
Pic = &SlavePic;
if (Value & PIC_ICW1)
if (Data & PIC_ICW1)
{
/* Start initialization */
Pic->Initialization = TRUE;
Pic->IntOffset = 0xFF;
Pic->CascadeRegisterSet = FALSE;
Pic->ConfigRegister = Value;
Pic->ConfigRegister = Data;
return;
}
if (Value & PIC_OCW3)
if (Data & PIC_OCW3)
{
/* This is an OCR3 */
if (Value == PIC_OCW3_READ_ISR)
if (Data == PIC_OCW3_READ_ISR)
{
/* Return the ISR on next read from command port */
Pic->ReadIsr = TRUE;
@@ -75,12 +94,12 @@ static VOID PicWriteCommand(BYTE Port, BYTE Value)
}
/* This is an OCW2 */
if (Value & PIC_OCW2_EOI)
if (Data & PIC_OCW2_EOI)
{
if (Value & PIC_OCW2_SL)
if (Data & PIC_OCW2_SL)
{
/* If the SL bit is set, clear a specific IRQ */
Pic->InServiceRegister &= ~(1 << (Value & PIC_OCW2_NUM_MASK));
Pic->InServiceRegister &= ~(1 << (Data & PIC_OCW2_NUM_MASK));
}
else
{
@@ -96,26 +115,30 @@ static VOID PicWriteCommand(BYTE Port, BYTE Value)
}
}
static BYTE PicReadData(BYTE Port)
static BYTE WINAPI PicReadData(USHORT Port)
{
/* Read the mask register */
if (Port == PIC_MASTER_DATA) return MasterPic.MaskRegister;
else return SlavePic.MaskRegister;
if (Port == PIC_MASTER_DATA)
return MasterPic.MaskRegister;
else // if (Port == PIC_SLAVE_DATA)
return SlavePic.MaskRegister;
}
static VOID PicWriteData(BYTE Port, BYTE Value)
static VOID WINAPI PicWriteData(USHORT Port, BYTE Data)
{
PPIC Pic;
/* Which PIC are we accessing? */
if (Port == PIC_MASTER_DATA) Pic = &MasterPic;
else Pic = &SlavePic;
if (Port == PIC_MASTER_DATA)
Pic = &MasterPic;
else // if (Port == PIC_SLAVE_DATA)
Pic = &SlavePic;
/* Is the PIC ready? */
if (!Pic->Initialization)
{
/* Yes, this is an OCW1 */
Pic->MaskRegister = Value;
Pic->MaskRegister = Data;
return;
}
@@ -123,7 +146,7 @@ static VOID PicWriteData(BYTE Port, BYTE Value)
if (Pic->IntOffset == 0xFF)
{
/* This is an ICW2, set the offset (last three bits always zero) */
Pic->IntOffset = Value & 0xF8;
Pic->IntOffset = Data & 0xF8;
/* Check if we are in single mode and don't need an ICW4 */
if ((Pic->ConfigRegister & PIC_ICW1_SINGLE)
@@ -139,7 +162,7 @@ static VOID PicWriteData(BYTE Port, BYTE Value)
if (!(Pic->ConfigRegister & PIC_ICW1_SINGLE) && !Pic->CascadeRegisterSet)
{
/* This is an ICW3 */
Pic->CascadeRegister = Value;
Pic->CascadeRegister = Data;
Pic->CascadeRegisterSet = TRUE;
/* Check if we need an ICW4 */
@@ -152,7 +175,7 @@ static VOID PicWriteData(BYTE Port, BYTE Value)
}
/* This must be an ICW4, we will ignore the 8086 bit (assume always set) */
if (Value & PIC_ICW4_AEOI)
if (Data & PIC_ICW4_AEOI)
{
/* Use automatic end-of-interrupt */
Pic->AutoEoi = TRUE;
@@ -162,46 +185,6 @@ static VOID PicWriteData(BYTE Port, BYTE Value)
Pic->Initialization = FALSE;
}
static BYTE WINAPI PicReadPort(USHORT Port)
{
switch (Port)
{
case PIC_MASTER_CMD:
case PIC_SLAVE_CMD:
{
return PicReadCommand(Port);
}
case PIC_MASTER_DATA:
case PIC_SLAVE_DATA:
{
return PicReadData(Port);
}
}
return 0;
}
static VOID WINAPI PicWritePort(USHORT Port, BYTE Data)
{
switch (Port)
{
case PIC_MASTER_CMD:
case PIC_SLAVE_CMD:
{
PicWriteCommand(Port, Data);
break;
}
case PIC_MASTER_DATA:
case PIC_SLAVE_DATA:
{
PicWriteData(Port, Data);
break;
}
}
}
/* PUBLIC FUNCTIONS ***********************************************************/
VOID PicInterruptRequest(BYTE Number)
@@ -301,17 +284,19 @@ BYTE PicGetInterrupt(VOID)
}
/* Spurious interrupt */
if (MasterPic.InServiceRegister & (1 << 2)) return SlavePic.IntOffset + 7;
else return MasterPic.IntOffset + 7;
if (MasterPic.InServiceRegister & (1 << 2))
return SlavePic.IntOffset + 7;
else
return MasterPic.IntOffset + 7;
}
VOID PicInitialize(VOID)
{
/* Register the I/O Ports */
RegisterIoPort(PIC_MASTER_CMD , PicReadPort, PicWritePort);
RegisterIoPort(PIC_SLAVE_CMD , PicReadPort, PicWritePort);
RegisterIoPort(PIC_MASTER_DATA, PicReadPort, PicWritePort);
RegisterIoPort(PIC_SLAVE_DATA , PicReadPort, PicWritePort);
RegisterIoPort(PIC_MASTER_CMD , PicReadCommand, PicWriteCommand);
RegisterIoPort(PIC_SLAVE_CMD , PicReadCommand, PicWriteCommand);
RegisterIoPort(PIC_MASTER_DATA, PicReadData , PicWriteData );
RegisterIoPort(PIC_SLAVE_DATA , PicReadData , PicWriteData );
}
@@ -348,6 +333,14 @@ call_ica_hw_interrupt(INT ms,
while (count-- > 0)
{
PicInterruptRequest(InterruptNumber);
/*
* FIXME: We should now restart 16-bit emulation and wait for its termination:
*
* "When the VDD calls VDDSimulateInterrupt, the address pointed to by
* the interrupt vector starts running in 16-bit mode. For an asynchronous
* interrupt, the VDD should create another thread and call VDDSimulateInterrupt
* from that thread."
*/
}
}
@@ -30,21 +30,6 @@
#define PIC_OCW3 (1 << 3)
#define PIC_OCW3_READ_ISR 0x0B
typedef struct _PIC
{
BOOLEAN Initialization;
BYTE MaskRegister;
BYTE IntRequestRegister;
BYTE InServiceRegister;
BYTE IntOffset;
BYTE ConfigRegister;
BYTE CascadeRegister;
BOOLEAN CascadeRegisterSet;
BOOLEAN AutoEoi;
BOOLEAN Slave;
BOOLEAN ReadIsr;
} PIC, *PPIC;
/* FUNCTIONS ******************************************************************/
VOID PicInterruptRequest(BYTE Number);
+1 -1
View File
@@ -509,7 +509,7 @@ VOID PitInitialize(VOID)
PitSetGate(2, FALSE);
/* Register the I/O Ports */
RegisterIoPort(PIT_COMMAND_PORT, NULL , PitWritePort);
RegisterIoPort(PIT_COMMAND_PORT, NULL, PitWritePort);
RegisterIoPort(PIT_DATA_PORT(0), PitReadPort, PitWritePort);
RegisterIoPort(PIT_DATA_PORT(1), PitReadPort, PitWritePort);
RegisterIoPort(PIT_DATA_PORT(2), PitReadPort, PitWritePort);
@@ -1482,7 +1482,7 @@ static VOID VgaUpdateTextCursor(VOID)
static BYTE WINAPI VgaReadPort(USHORT Port)
{
DPRINT("VgaReadPort: Port 0x%X\n", Port);
if (Port != VGA_DAC_MASK) SvgaHdrCounter = 0;
switch (Port)
@@ -2364,11 +2364,11 @@ BOOLEAN VgaInitialize(HANDLE TextHandle)
VgaClearMemory();
/* Register the I/O Ports */
RegisterIoPort(0x3CC, VgaReadPort, NULL); // VGA_MISC_READ
RegisterIoPort(0x3CC, VgaReadPort, NULL); // VGA_MISC_READ
RegisterIoPort(0x3C2, VgaReadPort, VgaWritePort); // VGA_MISC_WRITE, VGA_INSTAT0_READ
RegisterIoPort(0x3CA, VgaReadPort, NULL); // VGA_FEATURE_READ
RegisterIoPort(0x3CA, VgaReadPort, NULL); // VGA_FEATURE_READ
RegisterIoPort(0x3C0, VgaReadPort, VgaWritePort); // VGA_AC_INDEX, VGA_AC_WRITE
RegisterIoPort(0x3C1, VgaReadPort, NULL); // VGA_AC_READ
RegisterIoPort(0x3C1, VgaReadPort, NULL); // VGA_AC_READ
RegisterIoPort(0x3C4, VgaReadPort, VgaWritePort); // VGA_SEQ_INDEX
RegisterIoPort(0x3C5, VgaReadPort, VgaWritePort); // VGA_SEQ_DATA
RegisterIoPort(0x3C6, VgaReadPort, VgaWritePort); // VGA_DAC_MASK