Author: hbelusca Date: Thu Aug 13 17:20:04 2015 New Revision: 68709
URL: http://svn.reactos.org/svn/reactos?rev=68709&view=rev Log: [NTVDM] - 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.
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.h trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.c trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.h trunk/reactos/subsystems/mvdm/ntvdm/hardware/pit.c trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/svga.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hardw... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c [iso-8859-1] Thu Aug 13 17:20:04 2015 @@ -29,7 +29,7 @@ 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 @@ 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 @@ 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 @@ { 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 @@ case 0xF4: { Reporting = TRUE; + MouseResetCounters(); PS2QueuePush(PS2Port, MOUSE_ACK); break; } @@ -356,6 +351,7 @@ case 0xF5: { Reporting = FALSE; + MouseResetCounters(); PS2QueuePush(PS2Port, MOUSE_ACK); break; } @@ -366,6 +362,7 @@ /* Reset the configuration and counters */ MouseResetConfig(); MouseResetCounters(); + PS2QueuePush(PS2Port, MOUSE_ACK); break; }
@@ -380,7 +377,14 @@ /* 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 @@ }
/* Adjust for double vision */ - if (DoubleWidth) NewPosition.X /= 2; + if (DoubleWidth) NewPosition.X /= 2; if (DoubleHeight) NewPosition.Y /= 2;
WaitForSingleObject(MouseMutex, INFINITE);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hardw... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.h [iso-8859-1] Thu Aug 13 17:20:04 2015 @@ -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 {
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hardw... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.c [iso-8859-1] Thu Aug 13 17:20:04 2015 @@ -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 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 (Value & PIC_ICW1) + if (Port == PIC_MASTER_CMD) + Pic = &MasterPic; + else // if (Port == PIC_SLAVE_CMD) + Pic = &SlavePic; + + if (Data & PIC_ICW1) { /* Start initialization */ Pic->Initialization = TRUE; Pic->IntOffset = 0xFF; Pic->CascadeRegisterSet = FALSE; - Pic->ConfigRegister = Value; - return; - } - - if (Value & PIC_OCW3) + Pic->ConfigRegister = Data; + return; + } + + 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 @@ }
/* This is an OCW2 */ - if (Value & PIC_OCW2_EOI) - { - if (Value & PIC_OCW2_SL) + if (Data & PIC_OCW2_EOI) + { + 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 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; -} - -static VOID PicWriteData(BYTE Port, BYTE Value) + if (Port == PIC_MASTER_DATA) + return MasterPic.MaskRegister; + else // if (Port == PIC_SLAVE_DATA) + return SlavePic.MaskRegister; +} + +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 @@ 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 @@ 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 @@ }
/* 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; @@ -160,46 +183,6 @@
/* Done initializing */ 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 ***********************************************************/ @@ -301,17 +284,19 @@ }
/* 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 @@ 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." + */ } }
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hardw... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.h [iso-8859-1] Thu Aug 13 17:20:04 2015 @@ -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);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/pit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hardw... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/pit.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/pit.c [iso-8859-1] Thu Aug 13 17:20:04 2015 @@ -509,7 +509,7 @@ 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);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/svga.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hardw... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/svga.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/svga.c [iso-8859-1] Thu Aug 13 17:20:04 2015 @@ -1482,7 +1482,7 @@ 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 @@ 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