mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
[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++;
svn path=/trunk/; revision=64171
This commit is contained in:
parent
28b04f02e8
commit
a760af54a3
6 changed files with 57 additions and 39 deletions
|
@ -13,8 +13,17 @@
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "ps2.h"
|
#include "ps2.h"
|
||||||
|
|
||||||
|
/* PRIVATE VARIABLES **********************************************************/
|
||||||
|
|
||||||
static BYTE PS2Port = 0;
|
static BYTE PS2Port = 0;
|
||||||
|
|
||||||
|
/* PRIVATE FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
|
static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||||
|
|
||||||
VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent)
|
VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent)
|
||||||
|
@ -34,13 +43,11 @@ VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent)
|
||||||
// PicInterruptRequest(1);
|
// PicInterruptRequest(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID KeyboardCommand(BYTE Command)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOLEAN KeyboardInit(BYTE PS2Connector)
|
BOOLEAN KeyboardInit(BYTE PS2Connector)
|
||||||
{
|
{
|
||||||
|
/* Finish to plug the mouse to the specified PS/2 port */
|
||||||
PS2Port = PS2Connector;
|
PS2Port = PS2Connector;
|
||||||
|
PS2SetDeviceCmdProc(PS2Port, NULL, KeyboardCommand);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent);
|
VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent);
|
||||||
VOID KeyboardCommand(BYTE Command);
|
|
||||||
BOOLEAN KeyboardInit(BYTE PS2Connector);
|
BOOLEAN KeyboardInit(BYTE PS2Connector);
|
||||||
|
|
||||||
#endif // _KEYBOARD_H_
|
#endif // _KEYBOARD_H_
|
||||||
|
|
|
@ -136,31 +136,17 @@ static VOID MouseGetPacket(PMOUSE_PACKET Packet)
|
||||||
ButtonState = NewButtonState;
|
ButtonState = NewButtonState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
/*static*/ VOID MouseScroll(LONG Direction)
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
ScrollCounter += Direction;
|
ScrollCounter += Direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
COORD MouseGetPosition(VOID)
|
/*static*/ COORD MouseGetPosition(VOID)
|
||||||
{
|
{
|
||||||
return Position;
|
return Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MouseCommand(BYTE Command)
|
static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
{
|
{
|
||||||
switch (Command)
|
switch (Command)
|
||||||
{
|
{
|
||||||
|
@ -319,6 +305,20 @@ VOID MouseCommand(BYTE Command)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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)
|
BOOLEAN MouseInit(BYTE PS2Connector)
|
||||||
{
|
{
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
|
@ -341,7 +341,9 @@ BOOLEAN MouseInit(BYTE PS2Connector)
|
||||||
/* Release the device context */
|
/* Release the device context */
|
||||||
ReleaseDC(hWnd, hDC);
|
ReleaseDC(hWnd, hDC);
|
||||||
|
|
||||||
|
/* Finish to plug the mouse to the specified PS/2 port */
|
||||||
PS2Port = PS2Connector;
|
PS2Port = PS2Connector;
|
||||||
|
PS2SetDeviceCmdProc(PS2Port, NULL, MouseCommand);
|
||||||
|
|
||||||
MouseReset();
|
MouseReset();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -69,11 +69,6 @@ typedef struct _MOUSE_PACKET
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
VOID MouseEventHandler(PMOUSE_EVENT_RECORD MouseEvent);
|
VOID MouseEventHandler(PMOUSE_EVENT_RECORD MouseEvent);
|
||||||
|
|
||||||
VOID MouseScroll(LONG Direction);
|
|
||||||
COORD MouseGetPosition(VOID);
|
|
||||||
|
|
||||||
VOID MouseCommand(BYTE Command);
|
|
||||||
BOOLEAN MouseInit(BYTE PS2Connector);
|
BOOLEAN MouseInit(BYTE PS2Connector);
|
||||||
|
|
||||||
#endif // _MOUSE_H_
|
#endif // _MOUSE_H_
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
#include "ps2.h"
|
#include "ps2.h"
|
||||||
#include "pic.h"
|
#include "pic.h"
|
||||||
|
|
||||||
#include "keyboard.h"
|
|
||||||
#include "mouse.h"
|
|
||||||
|
|
||||||
/* PRIVATE VARIABLES **********************************************************/
|
/* PRIVATE VARIABLES **********************************************************/
|
||||||
|
|
||||||
#define BUFFER_SIZE 32
|
#define BUFFER_SIZE 32
|
||||||
|
@ -32,6 +29,9 @@ typedef struct _PS2_PORT
|
||||||
UINT QueueStart;
|
UINT QueueStart;
|
||||||
UINT QueueEnd;
|
UINT QueueEnd;
|
||||||
HANDLE QueueMutex;
|
HANDLE QueueMutex;
|
||||||
|
|
||||||
|
LPVOID Param;
|
||||||
|
PS2_DEVICE_CMDPROC DeviceCommand;
|
||||||
} PS2_PORT, *PPS2_PORT;
|
} PS2_PORT, *PPS2_PORT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -51,6 +51,14 @@ static BYTE OutputBuffer = 0x00; // PS/2 Output Buffer
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS **********************************************************/
|
/* 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)
|
static BYTE WINAPI PS2ReadPort(ULONG Port)
|
||||||
{
|
{
|
||||||
if (Port == PS2_CONTROL_PORT)
|
if (Port == PS2_CONTROL_PORT)
|
||||||
|
@ -238,10 +246,7 @@ static VOID WINAPI PS2WritePort(ULONG Port, BYTE Data)
|
||||||
*/
|
*/
|
||||||
case 0xD4:
|
case 0xD4:
|
||||||
{
|
{
|
||||||
if (Ports[1].IsEnabled)
|
PS2SendCommand(&Ports[1], Data);
|
||||||
// Ports[1].Function
|
|
||||||
MouseCommand(Data);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,10 +254,8 @@ static VOID WINAPI PS2WritePort(ULONG Port, BYTE Data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement PS/2 device commands
|
/* By default, send a command to the first PS/2 port */
|
||||||
if (Ports[0].IsEnabled)
|
PS2SendCommand(&Ports[0], Data);
|
||||||
// Ports[0].Function
|
|
||||||
KeyboardCommand(Data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,6 +304,14 @@ Done:
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
/* 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
|
// PS2SendToPort
|
||||||
BOOLEAN PS2QueuePush(BYTE PS2Port, BYTE Data)
|
BOOLEAN PS2QueuePush(BYTE PS2Port, BYTE Data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,8 +19,12 @@
|
||||||
#define PS2_DATA_PORT 0x60
|
#define PS2_DATA_PORT 0x60
|
||||||
#define PS2_CONTROL_PORT 0x64
|
#define PS2_CONTROL_PORT 0x64
|
||||||
|
|
||||||
|
typedef VOID (WINAPI *PS2_DEVICE_CMDPROC)(LPVOID Param, BYTE Command);
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
|
VOID PS2SetDeviceCmdProc(BYTE PS2Port, LPVOID Param, PS2_DEVICE_CMDPROC DeviceCommand);
|
||||||
|
|
||||||
BOOLEAN PS2QueuePush(BYTE PS2Port, BYTE Data);
|
BOOLEAN PS2QueuePush(BYTE PS2Port, BYTE Data);
|
||||||
|
|
||||||
VOID GenerateIrq1(VOID);
|
VOID GenerateIrq1(VOID);
|
||||||
|
|
Loading…
Reference in a new issue