Author: hbelusca
Date: Tue Sep 16 18:54:50 2014
New Revision: 64171
URL:
http://svn.reactos.org/svn/reactos?rev=64171&view=rev
Log:
[NTVDM]: We can specify device "command" procedures for each PS/2 port so that
when one writes to port 0x60, one can write to the correct device "plugged" into
it (keyboard, mouse). modularity++;
Modified:
trunk/reactos/subsystems/ntvdm/hardware/keyboard.c
trunk/reactos/subsystems/ntvdm/hardware/keyboard.h
trunk/reactos/subsystems/ntvdm/hardware/mouse.c
trunk/reactos/subsystems/ntvdm/hardware/mouse.h
trunk/reactos/subsystems/ntvdm/hardware/ps2.c
trunk/reactos/subsystems/ntvdm/hardware/ps2.h
Modified: trunk/reactos/subsystems/ntvdm/hardware/keyboard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/hardware/…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/hardware/keyboard.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/hardware/keyboard.c [iso-8859-1] Tue Sep 16 18:54:50
2014
@@ -13,7 +13,16 @@
#include "keyboard.h"
#include "ps2.h"
+/* PRIVATE VARIABLES **********************************************************/
+
static BYTE PS2Port = 0;
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
+{
+ UNIMPLEMENTED;
+}
/* PUBLIC FUNCTIONS ***********************************************************/
@@ -34,13 +43,11 @@
// PicInterruptRequest(1);
}
-VOID KeyboardCommand(BYTE Command)
-{
- UNIMPLEMENTED;
-}
-
BOOLEAN KeyboardInit(BYTE PS2Connector)
{
+ /* Finish to plug the mouse to the specified PS/2 port */
PS2Port = PS2Connector;
+ PS2SetDeviceCmdProc(PS2Port, NULL, KeyboardCommand);
+
return TRUE;
}
Modified: trunk/reactos/subsystems/ntvdm/hardware/keyboard.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/hardware/…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/hardware/keyboard.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/hardware/keyboard.h [iso-8859-1] Tue Sep 16 18:54:50
2014
@@ -22,7 +22,6 @@
/* FUNCTIONS ******************************************************************/
VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent);
-VOID KeyboardCommand(BYTE Command);
BOOLEAN KeyboardInit(BYTE PS2Connector);
#endif // _KEYBOARD_H_
Modified: trunk/reactos/subsystems/ntvdm/hardware/mouse.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/hardware/…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/hardware/mouse.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/hardware/mouse.c [iso-8859-1] Tue Sep 16 18:54:50 2014
@@ -136,31 +136,17 @@
ButtonState = NewButtonState;
}
-/* PUBLIC FUNCTIONS ***********************************************************/
-
-VOID MouseEventHandler(PMOUSE_EVENT_RECORD MouseEvent)
-{
- // FIXME: Sync our private data
-
- // HACK: Bypass PS/2 and instead, notify the
MOUSE.COM driver directly
- MouseBiosUpdatePosition(&MouseEvent->dwMousePosition);
- MouseBiosUpdateButtons(LOWORD(MouseEvent->dwButtonState));
-
- // PS2QueuePush(PS2Port, Data);
- // PicInterruptRequest(12);
-}
-
-VOID MouseScroll(LONG Direction)
+/*static*/ VOID MouseScroll(LONG Direction)
{
ScrollCounter += Direction;
}
-COORD MouseGetPosition(VOID)
+/*static*/ COORD MouseGetPosition(VOID)
{
return Position;
}
-VOID MouseCommand(BYTE Command)
+static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
{
switch (Command)
{
@@ -319,6 +305,20 @@
}
}
+/* PUBLIC FUNCTIONS ***********************************************************/
+
+VOID MouseEventHandler(PMOUSE_EVENT_RECORD MouseEvent)
+{
+ // FIXME: Sync our private data
+
+ // HACK: Bypass PS/2 and instead, notify the
MOUSE.COM driver directly
+ MouseBiosUpdatePosition(&MouseEvent->dwMousePosition);
+ MouseBiosUpdateButtons(LOWORD(MouseEvent->dwButtonState));
+
+ // PS2QueuePush(PS2Port, Data);
+ // PicInterruptRequest(12);
+}
+
BOOLEAN MouseInit(BYTE PS2Connector)
{
HWND hWnd;
@@ -341,7 +341,9 @@
/* Release the device context */
ReleaseDC(hWnd, hDC);
+ /* Finish to plug the mouse to the specified PS/2 port */
PS2Port = PS2Connector;
+ PS2SetDeviceCmdProc(PS2Port, NULL, MouseCommand);
MouseReset();
return TRUE;
Modified: trunk/reactos/subsystems/ntvdm/hardware/mouse.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/hardware/…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/hardware/mouse.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/hardware/mouse.h [iso-8859-1] Tue Sep 16 18:54:50 2014
@@ -69,11 +69,6 @@
/* FUNCTIONS ******************************************************************/
VOID MouseEventHandler(PMOUSE_EVENT_RECORD MouseEvent);
-
-VOID MouseScroll(LONG Direction);
-COORD MouseGetPosition(VOID);
-
-VOID MouseCommand(BYTE Command);
BOOLEAN MouseInit(BYTE PS2Connector);
#endif // _MOUSE_H_
Modified: trunk/reactos/subsystems/ntvdm/hardware/ps2.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/hardware/…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/hardware/ps2.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/hardware/ps2.c [iso-8859-1] Tue Sep 16 18:54:50 2014
@@ -16,9 +16,6 @@
#include "ps2.h"
#include "pic.h"
-#include "keyboard.h"
-#include "mouse.h"
-
/* PRIVATE VARIABLES **********************************************************/
#define BUFFER_SIZE 32
@@ -32,6 +29,9 @@
UINT QueueStart;
UINT QueueEnd;
HANDLE QueueMutex;
+
+ LPVOID Param;
+ PS2_DEVICE_CMDPROC DeviceCommand;
} PS2_PORT, *PPS2_PORT;
/*
@@ -50,6 +50,14 @@
static BYTE OutputBuffer = 0x00; // PS/2 Output Buffer
/* PRIVATE FUNCTIONS **********************************************************/
+
+static VOID PS2SendCommand(PPS2_PORT Port, BYTE Command)
+{
+ if (!Port->IsEnabled) return;
+
+ /* Call the device command */
+ if (Port->DeviceCommand) Port->DeviceCommand(Port->Param, Command);
+}
static BYTE WINAPI PS2ReadPort(ULONG Port)
{
@@ -238,10 +246,7 @@
*/
case 0xD4:
{
- if (Ports[1].IsEnabled)
- // Ports[1].Function
- MouseCommand(Data);
-
+ PS2SendCommand(&Ports[1], Data);
break;
}
}
@@ -249,10 +254,8 @@
return;
}
- // TODO: Implement PS/2 device commands
- if (Ports[0].IsEnabled)
- // Ports[0].Function
- KeyboardCommand(Data);
+ /* By default, send a command to the first PS/2 port */
+ PS2SendCommand(&Ports[0], Data);
}
}
@@ -300,6 +303,14 @@
}
/* PUBLIC FUNCTIONS ***********************************************************/
+
+VOID PS2SetDeviceCmdProc(BYTE PS2Port, LPVOID Param, PS2_DEVICE_CMDPROC DeviceCommand)
+{
+ if (PS2Port >= PS2_PORTS) return;
+
+ Ports[PS2Port].Param = Param;
+ Ports[PS2Port].DeviceCommand = DeviceCommand;
+}
// PS2SendToPort
BOOLEAN PS2QueuePush(BYTE PS2Port, BYTE Data)
Modified: trunk/reactos/subsystems/ntvdm/hardware/ps2.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/hardware/…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/hardware/ps2.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/hardware/ps2.h [iso-8859-1] Tue Sep 16 18:54:50 2014
@@ -19,7 +19,11 @@
#define PS2_DATA_PORT 0x60
#define PS2_CONTROL_PORT 0x64
+typedef VOID (WINAPI *PS2_DEVICE_CMDPROC)(LPVOID Param, BYTE Command);
+
/* FUNCTIONS ******************************************************************/
+
+VOID PS2SetDeviceCmdProc(BYTE PS2Port, LPVOID Param, PS2_DEVICE_CMDPROC DeviceCommand);
BOOLEAN PS2QueuePush(BYTE PS2Port, BYTE Data);